The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 895 - File: showthread.php PHP 7.2.34 (Linux)
File Line Function
/showthread.php 895 errorHandler->error




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Set end-thread hotkey
#1
Function SetEndThreadHotkey
Code:
Copy      Help
;/

function $hotkey

;Sets a hotkey to end current thread (running macro or function).

;hotkey - a single key without modifiers (Ctrl etc), specified as QM key code like with <help>key</help> and QM keyboard triggers.

;EXAMPLE
;SetEndThreadHotkey "F8"
;;macro
;rep
,;out 1
,;wait 1


int mod vk; if(!TO_HotkeyFromQmKeys(hotkey mod vk)) end "invalid hotkey string"
if(mod) end "modifier keys not supported"

QMTHREAD qt; GetQmThreadInfo(0 qt)
mac "sub.Thread" "" qt.threadhandle vk


#sub Thread
function ht vk

int- __ht82657(ht) __vk82657(vk)

int hh=SetWindowsHookEx(WH_KEYBOARD_LL &sub.Hook_WH_KEYBOARD_LL _hinst 0)
opt waitmsg 1
wait 0 H ht
UnhookWindowsHookEx hh


#sub Hook_WH_KEYBOARD_LL
function# nCode message KBDLLHOOKSTRUCT&k
if(nCode<0) goto gNext
if(k.flags&(LLKHF_UP|LLKHF_INJECTED)) goto gNext

int- __ht82657 __vk82657
if k.vkCode=__vk82657
,EndThread "" __ht82657
,ret 1

;gNext
ret CallNextHookEx(0 nCode message &k)

example
Macro Macro2718
Code:
Copy      Help
;add this line before the macro. Change the hotkey.
SetEndThreadHotkey "F12"

;your macro (example)
rep
,out 1
,wait 1

This can be useful where the common hotkey (Pause) cannot be used:
To end a non-macro thread (function etc).
When the macro has property "run simultaneously".
When you want to use a separate end-thread hotkey for some macros.
This also can be used to end .exe macros, but probably it's better to set hotkey in the "Make exe" dialog.


Messages In This Thread

Forum Jump:


Users browsing this thread: 4 Guest(s)