Jump to content

Detect and block a middle mouse button click

Recommended Posts

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)
        MouseMove($mPos[0], $mPos[1], 0)
        ToolTip(@SEC & @MSEC, Default, Default, "Last", 1, 1)     ;TEST


Link to post
Share on other sites

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

Func _MouseProc($iCode, $iwParam, $ilParam)
    If $iCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
    Switch $iwParam
            Return 1 ;disable
    Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
EndFunc   ;==>_MouseProc

Func _Close()
EndFunc   ;==>_Close


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...