Hey cracksloth,
cracksloth wrote:
Also, it took me forever to figure out that the remote example in the second post no longer works with the AHKHID version in the first post because of the recent addition of the prefix AHKHID rather than the old prefix HID.
You're right. Really sorry about that! I fixed the script.
As for your code, your main problem lies here:
Code:
iKey := AHKHID_GetInputData(lParam, uData)
SendInput %iKey% "{Enter}"
Compare this to the code found in the remote script:
Code:
;Get data
iKey := AHKHID_GetInputData(lParam, uData)
;Check for error
If (iKey <> -1) {
;Get keycode (located at the 6th byte)
iKey := NumGet(uData, 5, "UChar")
...
AHKHID_GetInputData only puts the data in the variable uData. It doesn't return the key pressed in iKey, so doing SendInput %iKey% is not what you want to do.
If you want to extract the key from uData, you need to find out which byte(s) it is in uData (in my example, it was the 6th byte).
If you just want to spit out all of uData, then you can do something like this:
Code:
;Get data
iKey := AHKHID_GetInputData(lParam, uData)
;Check for error
If (iKey <> -1) {
;iKey contains the length of uData
SendInput % Bin2Hex(&uData, iKey) "{Enter}"
}
which is exactly what I did when I modified Example 2 for the 3rd step of my tutorial.