SomeBody22 Posted September 7, 2019 Share Posted September 7, 2019 Hi, I'm coding a queue management. I need to bind the middle mouse button with the number generator function, ok it's easy. But, I need to remap or block the real function of the middle mouse button, because sometimes fails and clicks as a normal action... I will use other Windows functions at the same time, such as web browsing and if it fails, it will open new pages or close open tabs. #include <Misc.au3> While 1 If _IsPressed("04") Then $mPos = MouseGetPos() MouseMove(-1, -1, 0) MouseUp("middle") MouseMove($mPos[0], $mPos[1], 0) ToolTip(@SEC & @MSEC, Default, Default, "Last", 1, 1) ;TEST EndIf Sleep(10) WEnd Link to comment Share on other sites More sharing options...
mikell Posted September 7, 2019 Share Posted September 7, 2019 You might try this hook #include <WinAPI.au3> #include <WindowsConstants.au3> Global $hHook Local $hFunc, $pFunc, $hMod HotKeySet('{ESC}', '_Close') $hFunc = DllCallbackRegister('_MouseProc', 'lresult', 'int;int;int') $pFunc = DllCallbackGetPtr($hFunc) $hMod = _WinAPI_GetModuleHandle(0) $hHook = _WinAPI_SetWindowsHookEx($WH_MOUSE_LL, $pFunc, $hMod) While 1 Sleep(20) WEnd Func _MouseProc($iCode, $iwParam, $ilParam) If $iCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam) Switch $iwParam Case $WM_MBUTTONDOWN, $WM_MBUTTONUP Return 1 ;disable EndSwitch Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam) EndFunc ;==>_MouseProc Func _Close() _WinAPI_UnhookWindowsHookEx($hHook) DllCallbackFree($hHook) Exit EndFunc ;==>_Close SomeBody22, Gianni and pixelsearch 3 Link to comment Share on other sites More sharing options...
SomeBody22 Posted September 7, 2019 Author Share Posted September 7, 2019 Thanks, it's working fine. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now