Global $tRID_KD, $pRID_KD, $iRID_KD
Global $tRIH, $pRIH, $iRIH
Global $iNumDevices
Global $hGUI , $pData,$t
$on=1
$hGUI = GUICreate('Test', 100, 100)
GUIRegisterMsg($WM_INPUT, 'OnInput')
$tRID_KD = DllStructCreate($tagRAWINPUTDEVICE)
$pRID_KD = DllStructGetPtr($tRID_KD)
$iRID_KD = DllStructGetSize($tRID_KD)
$tRIH = DllStructCreate($tagRAWINPUTHEADER)
$pRIH = DllStructGetPtr($tRIH)
$iRIH = DllStructGetSize($tRIH)
$iNumDevices = 1
DllStructSetData($tRID_KD, 'usUsagePage', 0x01)
DllStructSetData($tRID_KD, 'usUsage', 0x06)
DllStructSetData($tRID_KD, 'dwFlags', BitOR($RIDEV_NOLEGACY, $RIDEV_INPUTSINK))
DllStructSetData($tRID_KD, 'hwndTarget', $hGUI)
_RegisterRawInputDevices($pRID_KD, $iNumDevices, $iRID_KD)
While 1
Sleep(10)
WEnd
Func OnInput($hwnd, $iMsg, $iwParam, $ilParam)
Local $tRI_KD, $pRI_KD, $iRI_KB
Local $tRIDI_HID, $pRIDI_HID, $iRIDI_HID
Local $hDevice
$tRI_KD = DllStructCreate($tagRAWINPUT_KEYBOARD)
$pRI_KD = DllStructGetPtr($tRI_KD)
$iRI_KB = DllStructGetSize($tRI_KD)
$tRIDI_HID = DllStructCreate($tagRIDDEVICEINFO_HID)
$pRIDI_HID = DllStructGetPtr($tRIDI_HID)
$iRIDI_HID = DllStructGetSize($tRIDI_HID)
;DllStructSetData($tRID_KD, 'dwFlags', BitOR($RIDEV_NOLEGACY, $RIDEV_INPUTSINK))
;672042073313Dll672042073313StructSetData($tRID_KD, 'dwFlags', BitOR($RIDEV_NOLEGACY, $RIDEV_INPUTSINK))
DllStructSetData($tRIDI_HID, 'cbSize', $iRIDI_HID)
_GetRawInputData($ilParam, $RID_INPUT, $pRI_KD, $iRI_KB, $iRIH)
If Not @error Then
$hDevice = DllStructGetData($tRI_KD, 'hDevice')
$vKey = DllStructGetData($tRI_KD, 'VKey');F3 = 114
EndIf
_GetRawInputDeviceInfo($hDevice, $RIDI_DEVICEINFO, $pRIDI_HID, $iRIDI_HID)
If Not @error Then
$hDevice2 = DllStructGetData($tRI_KD, 'hDevice')
$dwVendorId = DllStructGetData($tRIDI_HID, 'dwVendorId')
$dwProductId = DllStructGetData($tRIDI_HID, 'dwProductId')
$dwType = DllStructGetData($tRI_KD, 'dwType')
EndIf
If $dwVendorId = 81 Then
If $on Then
$t=$t&key($vKey)
ConsoleWrite($t&@CR)
$on=0
Else
$on=1
EndIf
EndIf
$tRI_KD = 0
if $vKey=13 Then
ConsoleWrite(121)
endif
endfunc
不知道为什么每个数字会出现2次,如果为字符会出现3次