evilC / AutoHotInterception

An AutoHotkey wrapper for the Interception driver
MIT License
707 stars 64 forks source link

subscribe all swallows it's own synthesised output #89

Closed mmelon closed 2 years ago

mmelon commented 2 years ago

Hi,

Just checking this is right. When i use

AHI.SubscribeKeyboard(id1, true, Func("KeyEvent"),false)

I can't

AHI.SendKeyEvent(id1, code, state)

because the subscription swallows the synthesised output? Or is there another reason I can't generate a keypress from within the subscribe keyEvent function?

Basically I want to subscribe all per device, then set a variable before allowing the key through. If I turn blocking off, the key is allowed through before the variable has been set.

I hope I have explained this ok.

thx Mike

evilC commented 2 years ago

No, AHI will never swallow it's own synthesized output. You're doing something wrong. In KeyEvent()... Is AHI in scope? Is id1 in scope?

ie WRONG:

AHI := new AutoHotInterception()
id1 := AHI.GetKeyboardId(0x04F2, 0x0112)
AHI.SubscribeKeyboard(id1, true, Func("KeyEvent"),false)

KeyEvent(code, state){
    AHI.SendKeyEvent(id1, code, state)
}

RIGHT:

AHI := new AutoHotInterception()
id1 := AHI.GetKeyboardId(0x04F2, 0x0112)
AHI.SubscribeKeyboard(id1, true, Func("KeyEvent"),false)

KeyEvent(code, state){
    global AHI, id1 ; <-- VITALLY IMPORTANT!!! Code cannot see values of AHI or id1 without this
    AHI.SendKeyEvent(id1, code, state)
}
mmelon commented 2 years ago

thx. AHI wasn't in scope. Feel a bit stupid but your response saved me so much time. thx again.