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)
#2
QM has similar 2-key triggers...

Maybe some of existing codes can be helpful:
[url]https://www.google.com/search?q=site%3Aquickmacros.com+"WH_KEYBOARD_LL"[/url]
#3
ok, but the demo did not seem to fit the bill for my usage, so i'll take it for framwork and try to adapt it..

TY Master!
#4
I mean regular QM triggers, not a demo code.
#5
i used that for generic test, but i need to be able to handle MANY possibilities (er,ed,es,ez couples of keys for instance) and don't want to create a macro for each,
as i mean to use them to behave differently depending on the windows the double keys are pressed.


Forum Jump:


Users browsing this thread: 1 Guest(s)