12-02-2015, 10:07 AM
Hi gintaras, hi all
I have a toobar linked to a specific window program. I manage it via a callback procedure as normal.
To make some task easier, i'd like to put a specific keyboard hook for that program only, and wait for a key sequence involving 2 keys, so the tasks are fired if those two keys only are pressed in a 1 second lapse.
If the key sequence is not listed in my action hook, it must be proceed as usual, if not, the sequence must be eaten and fire the associated action.
The framework is done (the hook function is called at toolbar creataion and closed at toolbar destroying), the key management is not working as I intend.
Any help to acheive that?
Thanks.
What I've done so far:
Function ToolbarHook1
Macro HookProc
I have a toobar linked to a specific window program. I manage it via a callback procedure as normal.
To make some task easier, i'd like to put a specific keyboard hook for that program only, and wait for a key sequence involving 2 keys, so the tasks are fired if those two keys only are pressed in a 1 second lapse.
If the key sequence is not listed in my action hook, it must be proceed as usual, if not, the sequence must be eaten and fire the associated action.
The framework is done (the hook function is called at toolbar creataion and closed at toolbar destroying), the key management is not working as I intend.
Any help to acheive that?
Thanks.
What I've done so far:
Function ToolbarHook1
function# hWnd message wParam lParam
;<help #IDH_EXTOOLBAR>Toolbar hook help</help>
;OutWinMsg message wParam lParam ;;uncomment to see received messages
sel message
,case WM_INITDIALOG
,mac "HookProc"
,
,case WM_DESTROY
,shutdown -6 0 "HookProc"
Macro HookProc
int hkey=SetWindowsHookEx(WH_KEYBOARD_LL &sub.KeyProc _hinst 0)
opt waitmsg 1
wait -1
UnhookWindowsHookEx hkey
#sub KeyProc
function nCode wParam KBDLLHOOKSTRUCT*x
if(strcmp(_s.getwintext(win) "ProgramWindow")!=0) goto gr
if(nCode!=HC_ACTION) goto gr
if(x.flags&LLKHF_UP=0) ret 1
Acc artyu.FromFocus
;POINT+ _m; xm _m
artyu.Role(_s)
if(strcmp(_s "TEXT")=0)
,DO_Action
,goto gr
ret 1
;gr
ret CallNextHookEx(0 nCode wParam &x)