Found a complicated way using AHKHID.
Via the example script_1.apk from here https://www.autohotkey.com/board/topic/38015-ahkhid-an-ahk-implementation-of-the-hid-functions / I get my keyboard code (there are 2 of them in the list). I insert my values
Code: Select all
ProdName = \\?\HID#VID_04D9&PID_FC41&MI_01#9&406d4c2&0&0000#{884b96c3-56ef-11d1-bc8c-00a0c91405dd
Code: Select all
Gui +LastFound -Resize -MaximizeBox -MinimizeBox
Gui, Add, Text, x0 y0 w400 h300 vt1 , none
GuiHandle := WinExist()
#include AHKHID.ahk
; plug constants AHKHID
AHKHID_UseConstants()
; Upon receipt of the message, start the function InputMsg
WM_INPUT := 0x00FF
OnMessage(WM_INPUT, "InputMsg")
; RIDEV_INPUTSINK - To accept messages in the background
keydoard := AHKHID_Register(1, 2, GuiHandle, RIDEV_INPUTSINK )
Return
;-----------------------------------------
; Processing an incoming message
InputMsg(wParam, lParam) {
Local DevHandle, VKey, sLabel, ProdName
Critical ;Or otherwise you could get ERROR_INVALID_HANDLE
;get II_DEVHANDLE
DevHandle := AHKHID_GetInputInfo(lParam, II_DEVHANDLE)
ProdName = % AHKHID_GetDevName(DevHandle, True) ;имя устройства
/* из example_1.ahk
my_264_Keys \\?\HID#VID_04D9&PID_FC41&MI_01#9&406d4c2&0&0000#{884b96c3-56ef-11d1-bc8c-00a0c91405dd}
my_173_Keys \\?\HID#VID_09DA&PID_90C0&MI_00&Col01#8&23ae9689&0&0000#{884b96c3-56ef-11d1-bc8c-00a0c91405dd}
если имя устройства как у моей клавиатуры
*/
if ProdName = \\?\HID#VID_04D9&PID_FC41&MI_01#9&406d4c2&0&0000#{884b96c3-56ef-11d1-bc8c-00a0c91405dd}
{
ToolTip, my_264_Keys ;not work
}
if ProdName = \\?\HID#VID_09DA&PID_90C0&MI_00&Col01#8&23ae9689&0&0000#{884b96c3-56ef-11d1-bc8c-00a0c91405dd}
{
ToolTip, my_173_Keys ;not work
}
;obviously, not work because it is not my keyboard, but logic for example
if ProdName = \\?\HID#VID_0518&PID_0001&MI_01&Col01#8&3125ebc9&0&0000#{378de44c-56ef-11d1-bc8c-00a0c91405dd}
{
; We get the button key
VKey = % AHKHID_GetInputInfo(lParam, II_KBD_VKEY)
; We get the name of the procedure of this button
sLabel := "Key_" VKey
; If there is such a procedure, we call it
If IsLabel(sLabel)
Gosub, %sLabel%
}
}
Sound() {
SoundPlay, %A_WinDir%\Media\ding.wav
}
;------------------------------------------------------------- appoint keys
;keyboard scroll up
Key_120:
SoundSet +5
Send, {WheelDown}
Sound()
Return
;keyboard scroll down
Key_65416:
SoundSet -5
Send, {WheelUp}
Sound()
Return
1. Where can I get my key codes? Like Key_120, Key_65416.
2. And how to sign the buttons correctly?
3. It would be good to know the experience of other Oscar product owners (not only keyboards, but also mice).
4. Or maybe there is a more officient way to bind special keys in AHK without AHKHID?