01-22-2017, 08:35 AM
With wait K not good.
This is another version, maybe will be easier to understand. At first create this member function.
Member function __RegisterHotKey.Register2
example
Macro Macro2766
This is another version, maybe will be easier to understand. At first create this member function.
Member function __RegisterHotKey.Register2
function! hWnd hkId $qmKeyCode
;Converts QM <help>key</help> codes qmKeyCode to mod/vk and calls <help>Register</help>.
;EXAMPLE
;__RegisterHotKey hk1.Register2(0 1 "CF10") ;;Ctrl+F10
int i k vk mod
rep
,i=QmKeyCodeToVK(qmKeyCode k)
,if(i=0) break
,qmKeyCode+i
,sel k
,,case VK_CONTROL mod|MOD_CONTROL
,,case VK_SHIFT mod|MOD_SHIFT
,,case VK_MENU mod|MOD_ALT
,,case VK_LWIN mod|MOD_WIN
,,case else vk=k
if(vk=0) end "no key"
ret Register(hWnd hkId mod vk)
example
Macro Macro2766
__RegisterHotKey hk1.Register2(0 1 "CF10") ;;Ctrl+F10
__RegisterHotKey hk2.Register2(0 2 "CF11")
MSG m
rep
,if(GetMessage(&m 0 0 0)<1) break
,if(m.message!=WM_HOTKEY) continue
,
,;edit this code if need. The numbers must match the numbers passed to Register2.
,sel m.wParam
,,case 1
,,sub.install ;;or can be: mac "sub.install"
,,
,,case 2
,,sub.uninstall ;;or can be: mac "sub.uninstall"
#sub install
out 1
#sub uninstall
out 2