08-17-2013, 01:26 PM
Ok here is the whole code, to be debugged and corrected.
Function generic_hook
Function generic_hook_Proc
Function TraiteTouches
the output is this one, pressing two key one after the other rapidly...seems near to do it, but miss something for being functional...
CurrentKey: P
OldKey: O
250
CurrentKey: M
OldKey: P
2422
CurrentKey: L
OldKey: M
297
CurrentKey: K
OldKey: L
5328
CurrentKey: I
OldKey: K
266
CurrentKey: J
OldKey: I
297
CurrentKey: U
OldKey: J
234
CurrentKey: H
OldKey: U
266
CurrentKey: Y
OldKey: H
250
CurrentKey: J
OldKey: Y
3453
CurrentKey: J
OldKey: J
156
CurrentKey: J
OldKey: J
719
CurrentKey: J
OldKey: J
156
Function generic_hook
int hh=SetWindowsHookEx(WH_KEYBOARD_LL &generic_hook_Proc _hinst 0)
str+ OldKey
int+ OldTime
out "Press a key"
opt waitmsg 1
wait -1
UnhookWindowsHookEx hh
Function generic_hook_Proc
function# nCode message KBDLLHOOKSTRUCT&k
int- TimeOld
if(nCode<0) goto gNext
if(!(k.flags&LLKHF_UP)) goto gNext ;;Si key down, on passe
int time=k.time
int code=k.vkCode
if(TraiteTouches(win time code)) ret 1
;gNext
ret CallNextHookEx(0 nCode message &k)
Function TraiteTouches
function int'hwnd int'time int'code
_i=0
int- timeold
_s.getwinexe(hwnd)
str jj
str chacun g
str monitor="qm"
FormatKeyString code 0 &jj
;out "%s %s%s" _s iif(k.flags&LLKHF_UP "up" "down") iif(k.flags&LLKHF_INJECTED ", injected" "") ;;debug
str+ CurrentKey=jj
out "CurrentKey: %s" CurrentKey
out "OldKey: %s" OldKey
OldKey=CurrentKey
int h=time-timeold
out h
timeold=time
foreach chacun monitor
,if(findrx(_s chacun 0 1 g)!=-1)
,,_i+1
,,break
if(_i=0) ret 1
the output is this one, pressing two key one after the other rapidly...seems near to do it, but miss something for being functional...
CurrentKey: P
OldKey: O
250
CurrentKey: M
OldKey: P
2422
CurrentKey: L
OldKey: M
297
CurrentKey: K
OldKey: L
5328
CurrentKey: I
OldKey: K
266
CurrentKey: J
OldKey: I
297
CurrentKey: U
OldKey: J
234
CurrentKey: H
OldKey: U
266
CurrentKey: Y
OldKey: H
250
CurrentKey: J
OldKey: Y
3453
CurrentKey: J
OldKey: J
156
CurrentKey: J
OldKey: J
719
CurrentKey: J
OldKey: J
156