The AutoHotkeyRemoteControlDLL.ahk script posted on the site only supports 9 HID/KB/MOUSE devices. To view more than that, this patch is required:
Code:
;
; AutoHotkey Version: 1.0.39.00
; Language: English/German
; Platform: WinXP
; Author: Michael Simon (MISIFUSC-MAIL@yahoo.de)
;
; Script Function:
; Support for
;
HomePath=AutohotkeyRemoteControl.dll
hModule := DllCall("LoadLibrary", "str", HomePath) ; Avoids the need for DllCall() to load the dll each call
;When receiving a WM_INPUT-message call the InputMsg-Label
OnMessage(0x00FF, "InputMsg")
;How many devices are attached?
nRC := DllCall("AutohotkeyRemoteControl\GetDeviceCount", "Cdecl UInt")
if errorlevel <> 0
{
MsgBox GetDeviceCount fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
devlb = ; ListboxInhalt
;Anzeige der Infos. Füllen der Listbox mit Devices
;Fill the listbox with the devicenames
loop, %nRC%
{
;msgbox %A_Index%
strRC := DllCall("AutohotkeyRemoteControl\GetDeviceType", Int, A_Index-1, "Cdecl Str")
if errorlevel <> 0
{
MsgBox GetDeviceType fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
ifequal, A_Index, 1
LBText2Add = %A_Index%: %strRC%
else
LBText2Add = %LBText2Add%|%A_Index%: %strRC%
}
;Gui, Add, ListBox, x6 y20 w460 h110 Choose1 gLBSelChange Vdevlb, %LBText2Add%
Gui, Add, ListBox, x6 y20 w460 h110 gLBSelChange Vdevlb, %LBText2Add%
Gui, Add, Text, x6 y0 w460 h20, Device Description
Gui, Add, Edit, x6 y130 w460 h110 VDevDesc, Device Info
Gui, Add, Edit, x6 y310 w100 h30 VEditUsage Number,
Gui, Add, Text, x6 y250 w330 h30,Enter Usage + UsagePage of the Ctrl`, then register it. Keyboard: Usage=6 Page=1 - Mouse: Usage=2 Page=1
Gui, Add, Text, x6 y280 w100 h30,Usage
Gui, Add, Text, x106 y280 w100 h30, UsagePage
Gui, Add, Edit, x106 y310 w100 h30 VEditUsagePage Number,
Gui, Add, Button, x216 y310 w90 h30 gRegisterCtrl,&Register
Gui, Add, Edit, x6 y370 w460 h290 vEditRespond,
Gui, Add, Text, x6 y340 w460 h12,Respond from Device:
Gui, Add, Text, x6 y352 w460 h12,
Gui, Show, x182 y192 h666 w474, Autohotkey HID-Support
return
LBSelChange:
;User has selected another item. /*Deregister all Devices and*/ Register the selected one
GuiControlGet, devlb
nWhereSpace := InStr(devlb, ":")
StringLeft, nCount, devlb, % nWhereSpace - 1
nRC := DllCall("AutohotkeyRemoteControl\GetDeviceCount", "Cdecl UInt")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox GetDeviceCount fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
;Get DeviceInfo
DevType = %devlb%
StringTrimLeft, DevType, DevType, % nWhereSpace + 1
if DevType = MOUSE
{
;msgbox Es ist eine Maus: %DevType%
;Get Mouse-Device-Information
DevID = 0
BtnNr = 0
SampleRate = 0
NameSize = 400
VarSetCapacity(Name, 500) ;Reserve more space than needed.
nRC := DllCall("AutohotkeyRemoteControl\GetMouseDeviceInfo", INT, nCount, "INT *", DevID, "INT *", BtnNr, "INT *", SampleRate, INT, NameSize, Str, Name, "Cdecl Int")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox error while calling GetMouseDeviceInfo Errorlevel: %errorlevel%
}
;Show Info in Edit
szText = DeviceID: %DevID%`nButtoncount:%BtnNr%`nSamplerate:%SampleRate%`nName:%Name%
GuiControl, , DevDesc, %szText%
GuiControl, , EditUsage, 2
GuiControl, , EditUsagePage, 1
}
if DevType = KEYBOARD
{
;Get Keyboard-Device-Information
nSubType = 0
nKeyboardMode = 0
nFuncKeyCount = 0
nIndicators = 0
nTotalKeys = 0
NameSize = 400
VarSetCapacity(Name, 500)
nRC := DllCall("AutohotkeyRemoteControl\GetKeyDeviceInfo", INT, nCount, "INT *", nSubType, "INT *", nKeyboardMode, "INT *", nFuncKeyCount, "INT *", nIndicators, "INT *", nTotalKeys, INT, NameSize, Str, Name, "Cdecl Int")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox error while calling GetKeyboardDeviceInfo Errorlevel: %errorlevel%
}
;Show Info in Edit
szText = SubType:%nSubType%, Keyboardmode:%nKeyboardMode%, FunctionKeys:%nFuncKeyCount%, Indicators:%nIndicators%, Total Keys:%nTotalKeys%, Name:%Name%
GuiControl, , DevDesc, %szText%
GuiControl, , EditUsage, 6
GuiControl, , EditUsagePage, 1
}
if DevType = HID
{
;Get HID-Device-Information
dwVendorId = 0
dwProductId = 0
dwVersionNumber = 0
usUsagePage = 0
usUsage = 0
NameSize = 400
VarSetCapacity(Name, 500)
nRC := DllCall("AutohotkeyRemoteControl\GetHIDDeviceInfo", INT, nCount, "INT *", dwVendorId, "INT *", dwProductId, "INT *", dwVersionNumber, "INT *", usUsagePage, "INT *", usUsage, INT, NameSize, Str, Name, "Cdecl Int")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox error while calling GetHIDDeviceInfo Errorlevel: %errorlevel%
}
;Show Info in Edit
szText = Vendor:%dwVendorId%, Product:%dwProductId%, VersionNr:%dwVersionNumber%, UsagePage:%usUsagePage%, Usage:%usUsage%, Name:%Name%
GuiControl, , EditUsage, %usUsage%
GuiControl, , EditUsagePage, %usUsagePage%
GuiControl, , DevDesc, %szText%
}
return
RegisterCtrl:
;Register a Control
HWND := WinExist("Autohotkey HID-Support")
GuiControlGet, EditUsage
GuiControlGet, EditUsagePage
;MsgBox -%HWND%- >>%EditUsage%<< >%EditUsagePage%<
nRC := DllCall("AutohotkeyRemoteControl\RegisterDevice", INT, EditUsage, INT, EditUsagePage, INT, HWND, "Cdecl UInt")
if (errorlevel <> 0) || (nRC == -1)
{
MsgBox RegisterDevice fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
return
;This function is called, when an WM_INPUT-msg from a device is received
InputMsg(wParam, lParam, msg, hwnd)
{
;MsgBox %wParam% %lParam%
;MsgBox eingetroffen %wParam% %lParam% %msg% %HWND%
DeviceNr = -1
nRC := DllCall("AutohotkeyRemoteControl\GetWM_INPUTDataType", UINT, wParam, UINT, lParam, "INT *", DeviceNr, "Cdecl UInt")
if (errorlevel <> 0) || (nRC == 0xFFFFFFFF)
{
MsgBox GetWM_INPUTHIDData fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
;Tooltip, %DeviceNr%
ifequal, nRC, 0
{
GetMouseData(wParam, lParam)
}
else ifequal, nRC, 1
{
GetKeyboardData(wParam, lParam)
}
else ifequal, nRC, 2
{
GetHIDData(wParam, lParam)
}
}
return
GetHIDData(wParam, lParam)
{
DataSize = 5000
VarSetCapacity(RawData, %DataSize%)
nHandle := DllCall("AutohotkeyRemoteControl\GetWM_INPUTHIDData", UINT, wParam, UINT, lParam, "UINT *" , DataSize, "UINT *", RawData, "Cdecl UInt")
if (errorlevel <> 0) || (nHandle == -1)
{
MsgBox GetWM_INPUTHIDData fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
DeviceNumber := DllCall("AutohotkeyRemoteControl\GetNumberFromHandle", INT, nHandle, "Cdecl Int")
DeviceNumber := DeviceNumber +1 ;Index 0
;Msgbox, %DataSize%
loop, %DataSize%
{
Zeichen := ExtractInteger(RawData, A_Index, false, 1)
Vals = %Vals% - %Zeichen%
}
;MsgBox %Vals%
Vals = %Vals% `n
GuiControlGet, EditRespond
OldText = %EditRespond%
OldText = %Vals% %OldText%
StringLeft, OldText, OldText, 300
GuiControl, , EditRespond, %OldText%
ControlSetText, Static6, %DeviceNumber%
;MsgBox %Vals%
}
GetMouseData(wParam, lParam)
{
nHandle := DllCall("AutohotkeyRemoteControl\GetWM_INPUTMOUSEData", UINT, wParam, UINT, lParam, "UINT *" , pusFlags, "UINT *", pusBtnFlg
, "UINT *" , pusBtnData, "UINT *", pulRawBtn, "UINT *" , px, "UINT *", py, "UINT *", pextraInfo, "Cdecl UInt")
if (errorlevel <> 0) || (nHandle == -1)
{
MsgBox GetWM_INPUTHIDData fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
DeviceNumber := DllCall("AutohotkeyRemoteControl\GetNumberFromHandle", INT, nHandle, "Cdecl Int")
DeviceNumber := DeviceNumber +1 ;Index 0
Text = Flags: %pusFlags% `nBtnFlag: %pusBtnFlg% `nButtonData: %pusBtnData% `nRawButton: %pulRawBtn% `nX: %px% `nY: %py% `nExtrainfo: %pextraInfo%
GuiControlGet, EditRespond
OldText = %EditRespond%
StringLeft, OldText, OldText, 500
GuiControl, , EditRespond, %Text%`n%OldText%
ControlSetText, Static6, %DeviceNumber%
}
return
GetKeyboardData(wParam, lParam)
{
nHandle := DllCall("AutohotkeyRemoteControl\GetWM_INPUTKEYBOARDData", UINT, wParam, UINT, lParam, "UINT *" , pusMakeCode, "UINT *", pusFlags
, "UINT *" , pusKey, "UINT *", punMsg, "UINT *", pextraInfo, "Cdecl UInt")
if (errorlevel <> 0) || (nHandle == -1)
{
MsgBox GetWM_INPUTHIDData fehlgeschlagen. Errorcode: %errorlevel%
goto cleanup
}
DeviceNumber := DllCall("AutohotkeyRemoteControl\GetNumberFromHandle", INT, nHandle, "Cdecl Int")
DeviceNumber := DeviceNumber +1 ;Index 0
Text = MakeCode: %pusMakeCode% `nFlags: %pusFlags% `nKey: %pusKey% `nMsg: %punMsg% `nExtrainfo: %pextraInfo%
GuiControlGet, EditRespond
OldText = %EditRespond%
StringLeft, OldText, OldText, 500
GuiControl, , EditRespond, %Text%`n%OldText%
ControlSetText, Static6, %DeviceNumber%
}
return
GuiClose:
ExitApp
cleanup:
DllCall("FreeLibrary", "UInt", hModule) ; It is best to unload the DLL after using it (or before the script exits).
ExitApp
ExtractInteger(ByRef pSource, pOffset = 0, pIsSigned = false, pSize = 4)
; pSource is a string (buffer) whose memory area contains a raw/binary integer at pOffset.
; The caller should pass true for pSigned to interpret the result as signed vs. unsigned.
; pSize is the size of PSource's integer in bytes (e.g. 4 bytes for a DWORD or Int).
; pSource must be ByRef to avoid corruption during the formal-to-actual copying process
; (since pSource might contain valid data beyond its first binary zero).
{
SourceAddress := &pSource + pOffset ; Get address and apply the caller's offset.
result := 0 ; Init prior to accumulation in the loop.
Loop %pSize% ; For each byte in the integer:
{
result := result | (*SourceAddress << 8 * (A_Index - 1)) ; Build the integer from its bytes.
SourceAddress += 1 ; Move on to the next byte.
}
if (!pIsSigned OR pSize > 4 OR result < 0x80000000)
return result ; Signed vs. unsigned doesn't matter in these cases.
; Otherwise, convert the value (now known to be 32-bit) to its signed counterpart:
return -(0xFFFFFFFF - result + 1)
}
I also am trying to figure out the same question above. Is there a way to suppress WM_INPUT from being sent to other applications?