Flaccid_Jack 0 Posted March 20, 2020 Hello, Scenario: Two mouses plugged into the same computer. Would it be possible for AutoIt to disable and enable one mouse or the other? Or somehow assign different handles to each of the mouses clicks? (E.G. $hwnd1 = left click for mouse1 and $hwnd2 = left click for mouse2) Thank you for your time Share this post Link to post Share on other sites
Jos 2,165 Posted March 20, 2020 How would multiple input devices even work properly on any Windows application? Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Share this post Link to post Share on other sites
Nine 925 Posted March 20, 2020 I think I have found a way. Let me test it tomorrow, as I am too tired tonight to continue. But if you want to invest time to understand your issue I would suggest you read about _WinAPI_EnumRawInputDevices and their related functions _WinAPI_GetRawInputDeviceInfo, _WinAPI_GetRawInputData. Anyway tomorrow I shall post something interesting... Not much of a signature, but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Tool to search content in au3 files Date Range Picker Sudoku Game 2020 Overlapped Named Pipe IPC x64 Bitwise Operations Fast and simple WCD IPC GIF Animation (cached) Share this post Link to post Share on other sites
Nine 925 Posted March 21, 2020 (edited) Ok found some energy (curiosity ?), I tested on 2 different mouses and it works perfect... expandcollapse popup#include <Constants.au3> #include <GUIConstants.au3> #include <Array.au3> #include <WinAPISys.au3> Opt("MustDeclareVars", 1) Global Const $HWND_MESSAGE = -3 Global Const $HID_USAGE_PAGE_GENERIC = 0x1 Global Const $HID_USAGE_GENERIC_MOUSE = 0x2 Global $aMouses = EnumRawMouses("\HID") If Not IsArray($aMouses) Or Not $aMouses[0][0] Then Exit MsgBox($MB_SYSTEMMODAL, "", "Unable to find mouse device") Global $hTarget = GUICreate("", 10, 10, Default, Default, Default, Default, $HWND_MESSAGE) Register_RawInput($HID_USAGE_PAGE_GENERIC, $HID_USAGE_GENERIC_MOUSE, $RIDEV_INPUTSINK, $hTarget) GUIRegisterMsg($WM_INPUT, 'WM_INPUT') HotKeySet("{ESC}", _Exit) While 1 Sleep(100) WEnd Func _Exit() Exit EndFunc ;==>_Exit Func Register_RawInput($iUsagePage, $iUsage, $iFlags, $hTargetHwnd) Local $tRID = DllStructCreate($tagRAWINPUTDEVICE) DllStructSetData($tRID, 'UsagePage', $iUsagePage) DllStructSetData($tRID, 'Usage', $iUsage) DllStructSetData($tRID, 'Flags', $iFlags) DllStructSetData($tRID, 'hTarget', $hTargetHwnd) _WinAPI_RegisterRawInputDevices($tRID) EndFunc ;==>Register_RawInput Func WM_INPUT($hWnd, $iMsg, $wParam, $lParam) ;Callback from RawInput Local $tRIM = DllStructCreate($tagRAWINPUTMOUSE), $hDevice, $iMouse = 0 If _WinAPI_GetRawInputData($lParam, $tRIM, DllStructGetSize($tRIM), $RID_INPUT) Then $hDevice = "0x" & Hex(DllStructGetData($tRIM, "hDevice")) For $i = 1 To $aMouses[0][0] If $hDevice = $aMouses[$i][0] Then $iMouse = $i Next Local $iFlags = DllStructGetData($tRIM, 'ButtonFlags') Local $sEvent = $iFlags & " / " If BitAND($iFlags, BitOR($RI_MOUSE_MIDDLE_BUTTON_DOWN, $RI_MOUSE_MIDDLE_BUTTON_UP, $RI_MOUSE_LEFT_BUTTON_DOWN, $RI_MOUSE_LEFT_BUTTON_UP, _ $RI_MOUSE_RIGHT_BUTTON_DOWN, $RI_MOUSE_RIGHT_BUTTON_UP)) Then If BitAND($iFlags, $RI_MOUSE_MIDDLE_BUTTON_DOWN) Then $sEvent &= "RI_MOUSE_MIDDLE_BUTTON_DOWN / " If BitAND($iFlags, $RI_MOUSE_MIDDLE_BUTTON_UP) Then $sEvent &= "RI_MOUSE_MIDDLE_BUTTON_UP / " If BitAND($iFlags, $RI_MOUSE_LEFT_BUTTON_DOWN) Then $sEvent &= "RI_MOUSE_LEFT_BUTTON_DOWN / " If BitAND($iFlags, $RI_MOUSE_LEFT_BUTTON_UP) Then $sEvent &= "RI_MOUSE_LEFT_BUTTON_UP / " If BitAND($iFlags, $RI_MOUSE_RIGHT_BUTTON_DOWN) Then $sEvent &= "RI_MOUSE_RIGHT_BUTTON_DOWN / " If BitAND($iFlags, $RI_MOUSE_RIGHT_BUTTON_UP) Then $sEvent &= "RI_MOUSE_RIGHT_BUTTON_UP / " EndIf If Not $iFlags Then $sEvent &= "MOUSE_MOVE / " If BitAND($iFlags, $RI_MOUSE_WHEEL) Then Local $aData = _WinAPI_WordToShort(DllStructGetData($tRIM, 'ButtonData')) If $aData > 0 Then $sEvent &= 'Up / ' Else $sEvent &= 'Down / ' EndIf EndIf ConsoleWrite("Mouse " & $iMouse & " = " & $sEvent & DllStructGetData($tRIM, "LastX") & "/" & DllStructGetData($tRIM, "LastY") & @CRLF) EndIf Return $GUI_RUNDEFMSG EndFunc ;==>WM_INPUT Func EnumRawMouses($sDeviceNameMatch = "") Local Const $tagRID_INFO_MOUSE = "dword Size;dword Type;struct;dword Id;dword NumberOfButtons;dword SampleRate;int HasHorizontalWheel;endstruct;dword Unused[2];" Local $aData = _WinAPI_EnumRawInputDevices() If Not IsArray($aData) Then Exit MsgBox($MB_SYSTEMMODAL, "", "Enum input devices didn't work") ;_ArrayDisplay($aData) Local $aMouses[$aData[0][0]][7] Local $iCount = 0, $iSize Local $tInfo = DllStructCreate($tagRID_INFO_MOUSE), $tDeviceName, $sDeviceName For $i = 1 To $aData[0][0] If $aData[$i][1] = $RIM_TYPEMOUSE And _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tInfo, DllStructGetSize($tInfo), $RIDI_DEVICEINFO) Then $iSize = _WinAPI_GetRawInputDeviceInfo($aData[$i][0], 0, 0, $RIDI_DEVICENAME) ;Get bytes needed $tDeviceName = DllStructCreate('wchar[' & $iSize + 1 & ']') ;Holds device name string If _WinAPI_GetRawInputDeviceInfo($aData[$i][0], $tDeviceName, DllStructGetSize($tDeviceName), $RIDI_DEVICENAME) Then $sDeviceName = DllStructGetData($tDeviceName, 1) If $sDeviceNameMatch <> "" And Not StringInStr($sDeviceName, $sDeviceNameMatch) Then ContinueLoop $iCount += 1 $aMouses[$iCount][0] = $aData[$i][0] ;Handle $aMouses[$iCount][1] = $aData[$i][1] ;Type $aMouses[$iCount][2] = $sDeviceName $aMouses[$iCount][3] = DllStructGetData($tInfo, "Id") $aMouses[$iCount][4] = DllStructGetData($tInfo, "NumberOfButtons") $aMouses[$iCount][5] = DllStructGetData($tInfo, "SampleRate") $aMouses[$iCount][6] = DllStructGetData($tInfo, "HasHorizontalWheel") EndIf EndIf Next $aMouses[0][0] = $iCount ReDim $aMouses[$iCount + 1][7] ;_ArrayDisplay($aMouses) Return $aMouses EndFunc ;==>EnumRawMouses Edited March 21, 2020 by Nine 1 Aelc reacted to this Not much of a signature, but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Tool to search content in au3 files Date Range Picker Sudoku Game 2020 Overlapped Named Pipe IPC x64 Bitwise Operations Fast and simple WCD IPC GIF Animation (cached) Share this post Link to post Share on other sites
Flaccid_Jack 0 Posted March 23, 2020 Wow thanks Nine! Stay safe Share this post Link to post Share on other sites
Nine 925 Posted March 23, 2020 You too Jack. Not much of a signature, but working on it... Spoiler Block all input without UAC Save/Retrieve Images to/from Text Tool to search content in au3 files Date Range Picker Sudoku Game 2020 Overlapped Named Pipe IPC x64 Bitwise Operations Fast and simple WCD IPC GIF Animation (cached) Share this post Link to post Share on other sites