Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can I use this to record key's sequence entered from specific keyboard? #27

Open
AlexZhouAA opened this issue Jan 25, 2019 · 1 comment

Comments

@AlexZhouAA
Copy link

AlexZhouAA commented Jan 25, 2019

I am pretty new to AHK script. I very appreciate the wonderful work you did.
I try to record the sequence of certain keys entered from a specific keyboard, and block them at the same time using the following code

#SingleInstance force
#Persistent
#include Lib\AutoHotInterception.ahk

global AHI := new AutoHotInterception()
keyboardId := AHI.GetKeyboardId(0x5131, 0x2007)
str := ""
keys := ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "Enter", "?", ";"]
Loop 13 {
    name := keys[A_Index]	
    AHI.SubscribeKey(keyboardId, GetKeySC(name), true, Func("KeyEvent").Bind(name))
}
KeyEvent(name, state){
    global str
    if(state == 1){
       return
    }
   if(name != "Enter"){
	str .= name
   } else {
	xx := str
	str := ""
	MsgBox % xx		
   }
}

^Esc::
   ExitApp

Most time I got the right sequence, but sometime the "Enter" key won't be blocked.
Sometime I got the wrong sequence, like I enter 123456, it shows me like 213456.
That means the KeyEvent not firing in order.

I don't know what to do now, or maybe you have a better idea to implement the purpose mentioned at the beginning.

Thanks a lot

@evilC
Copy link
Owner

evilC commented Jan 30, 2019

Cannot reproduce this issue on my PC, your script works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants