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

How to get DeviceID for a specific button pressed? #6

Open
MasterGroosha opened this issue Jun 20, 2017 · 4 comments
Open

How to get DeviceID for a specific button pressed? #6

MasterGroosha opened this issue Jun 20, 2017 · 4 comments

Comments

@MasterGroosha
Copy link

Hello, Sir.
I have troubles with understanding the documentation, could you please point me to the right direction?

I have a "laptop" with keyboard and touchpad. Unfortunately, the touchpad is somehow "hacked" by chinese manufacturers, so it has smart gestures emulated. So whenever I swipe left on touchpad, it sends "Left Windows" button.
As far as I see, I can try filtering such buttons by getting DeviceID of keyboard & touchpad and simply ignoring "Left Windows" sends by touchpad.

GetDevInfo function requiers an index. However is there any way to get device which send a specific button?

@MasterGroosha
Copy link
Author

So, I'm using your example №2 to get info for "Left Windows" button.
Rows 1 & 2 are from keyboard while rows 3 & 4 are from touchpad. You see, there is no difference, and I cannot get any specific info about devices. What modifications to example №2 should I make to get at least DeviceIDs? And how to filter them later using AHKHID?
image

@MasterGroosha
Copy link
Author

So somehow I managed to get handle (?) of device. However I don't know how to filter input based on that handle (?) and how to make it permanent. I guess the numbers will change after reboot.

#NoEnv
#SingleInstance force
SendMode Input
SetWorkingDir %A_ScriptDir%
#Include AHKHID.ahk

AHKHID_UseConstants()

;Intercept WM_INPUT
OnMessage(0x00FF, "InputMsg")
AHKHID_AddRegister(1)
AHKHID_AddRegister(1, 6, 0)
AHKHID_Register()

iCount := AHKHID_GetRegisteredDevs(uDev)
msgbox, %iCount%

OnMessage(0x00FF, "InputMsg")

InputMsg(wParam, lParam) {
    Local r, h
    Critical    ;Or otherwise you could get ERROR_INVALID_HANDLE
    
    ;Get device type
    d_handle := AHKHID_GetInputInfo(lParam, II_DEVHANDLE)
    btn_id := AHKHID_GetInputInfo(lParam, II_KBD_VKEY) 
}

@MasterGroosha
Copy link
Author

And the core problem is that setting AHKHID_AddRegister(1, 6, 0, RIDEV_INPUTSINK) doesn't allow to grab input from any window, only when script is in foreground (despine RIDEV_INPUTSINK being set)

@ghost
Copy link

ghost commented Dec 11, 2019

I have the same problem. I can't obtain which keyboard has send the key.

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

1 participant