Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Hook for specific window
#1
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
Code:
Copy      Help
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
Code:
Copy      Help
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)


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)