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.

;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     ?
;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.
Gintaras
Site Admin
 
Posts: 10254
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Set end-thread hotkey

Postby conanjou on Fri Mar 03, 2017 4:22 am

Why do I use the function of SetEndThreadHotkey, one computer(win10) can run, but the others(win10, win7) can't run?
Appreciate your advice.
conanjou
 
Posts: 33
Joined: Wed Sep 25, 2013 2:28 pm

Re: Set end-thread hotkey

Postby Gintaras on Fri Mar 03, 2017 6:49 am

Need more info about "can't run". Does it show an error message?
Gintaras
Site Admin
 
Posts: 10254
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Set end-thread hotkey

Postby conanjou on Fri Mar 03, 2017 7:11 am

QM doesn't show any error message.
I run the example as below

Macro Macro12     ?
SetEndThreadHotkey "F8"
;macro
rep
,out 1
,wait 1


One computer can run successfully, and Running item's(QM) Threads show "SetEndThreadHotkey:Thread"
The other computers can't run successfully, it can run marco rep, but don't show "SetEndThreadHotkey:Thread".
conanjou
 
Posts: 33
Joined: Wed Sep 25, 2013 2:28 pm

Re: Set end-thread hotkey

Postby Gintaras on Fri Mar 03, 2017 7:17 am

And F8 does not work? Maybe don't show "SetEndThreadHotkey:Thread" because it is hidden. It depends on QM settings. Look in Options / General / Show hidden Running items.
Gintaras
Site Admin
 
Posts: 10254
Joined: Thu Dec 19, 2002 7:36 pm
Location: Lithuania

Re: Set end-thread hotkey

Postby conanjou on Fri Mar 03, 2017 7:26 am

Thanks, it can't run early, but it can run now...
and thanks for your information about QM settings.
conanjou
 
Posts: 33
Joined: Wed Sep 25, 2013 2:28 pm

Re: Set end-thread hotkey

Postby Martinsen on Fri May 19, 2017 8:04 am

Gintaras wrote:And F8 does not work? Maybe don't show "SetEndThreadHotkey:Thread" because it is hidden. It depends on QM settings. Look in Options / General / Show hidden Running items.


What does pressing F8 supposed to do?
Martinsen
 
Posts: 1
Joined: Thu May 11, 2017 2:33 pm


Return to QM Extensions

Who is online

Users browsing this forum: No registered users and 1 guest

cron