Set end-thread hotkey

Functions, classes, components, etc. Only high quality content.

Set end-thread hotkey

Postby Gintaras on Fri Jul 29, 2016 5:08 am

Function SetEndThreadHotkey     ?

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.

;SetEndThreadHotkey "F8"
,;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

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

ret CallNextHookEx(0 nCode message &k)

Macro Macro2718     ?
;add this line before the macro. Change the hotkey.
SetEndThreadHotkey "F12"

;your macro (example)
,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.
Site Admin
Posts: 10136
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Return to QM Extensions

Who is online

Users browsing this forum: No registered users and 1 guest