Jump to content

Prevent Mouse Right Click Menu?

Recommended Posts

I wrote a little application to remote control a music player application with one of my multi-button mouses.

Is there a way to prevent the right click menu from appearing but still allow the right click button to register?

I also want to track the mouse wheel so I can control volume.  Anyway to do that also?

There was no mention in the manual about these two things, not sure if there is another way to go about this.

Link to post
Share on other sites

I am not interested in SENDING these commands.. I want to track through something like _isPressed or some similar function to register physical mouse clicks, scroll wheel turn front or back and also the  middle mouse click which that exists.

Link to post
Share on other sites

Here it is  :)

#include <WinAPI.au3>
#include <WindowsConstants.au3>

HotKeySet('{ESC}', '_Close')

Global Const $tagMSLLHOOKSTRUCT = $tagPOINT & ';uint mouseData;uint flags;uint time;ulong_ptr dwExtraInfo;'
Global $hFunc, $pFunc, $hHook, $hMod, $iCounter = 0 ; The wheel counter
$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)
    Local $tMSLL, $iDelta
    If $iCode < 0 Then Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)
    $tMSLL = DllStructCreate($tagMSLLHOOKSTRUCT, $ilParam)
    Switch $iwParam
     Case $WM_RBUTTONUP   ; right ckick
        ConsoleWrite("Right click" & @LF) ; <<<< some action here
        Return 1   ;<<<<<<< without further condition setting this disables right click everywhere (context menus etc)
     Case $WM_MBUTTONUP ; middle click
        ConsoleWrite("Middle button click" & @LF)
     Case $WM_MOUSEWHEEL ; mouse wheel
        $iDelta = BitShift(DllStructGetData($tMSLL, 'mouseData'), 16)
        If $iDelta < 0 Then
            $iCounter -= 1
            $iCounter += 1
        ConsoleWrite($iCounter & @LF)
       ; Return 1 ; <<<< ditto  
    Return _WinAPI_CallNextHookEx($hHook, $iCode, $iwParam, $ilParam)

Func _Close()


Edited by mikell
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...