Jump to content

Recommended Posts

Posted (edited)

So I would like to write a script that will perform a certain action when the script detects that the mouse wheel has been scrolled up or down, but not pressed.  I would like it to work in much the same way that a script would perform a certain action when a key is pressed:

#include <Misc.au3>

Do
    Sleep ( 250 )
Until _IsPressed (04)

;do stuff here

But instead of waiting for the middle mouse button to be pressed, script would wait until it detects it has been scrolled.  Any thoughts on how to accomplish this?

Edited by whiggs2
Posted (edited)

First have a look here and download the UDF or whatever.

Set some functions to flag variables.  Name the functions any valid function name.  I have kept the misspelling from the tutorial.

;mouse event functions
Func MOUSE_WHELLSCROLL_DOWN()
    ConsoleWrite(@CRLF & "!MOUSE WHEEL DOWN")
    $gMb_wheel_down = 1
EndFunc;MOUSE_WHELLSCROLL_DOWN()

Func MOUSE_WHELLSCROLL_UP()
    ConsoleWrite(@CRLF & "!MOUSE WHEEL UP")
    $gMb_wheel_up = 1
EndFunc;MOUSE_WHELLSCROLL_UP()

Assign those functions to be called on mouse wheel up | down.  You might have to do this after you create a GUI window Idk.

_MouseSetOnEvent_RI($MOUSE_WHEELSCROLLUP_EVENT, "MOUSE_WHELLSCROLL_UP", $hGui)
_MouseSetOnEvent_RI($MOUSE_WHEELSCROLLDOWN_EVENT, "MOUSE_WHELLSCROLL_DOWN", $hGui)

Now you can check the variables to test for true.  If true, switch them back off and maybe do some action.

If $gMb_wheel_up = 1 Then
    $gMb_wheel_up = 0
    Exit
EndIf

 

Edited by Xandy
Posted
8 minutes ago, Xandy said:

First have a look here and download the UDF or whatever.

Set some functions to flag variables.  Name the functions any valid function name.  I have kept the misspelling form the tutorial.

;mouse event functions
Func MOUSE_WHELLSCROLL_DOWN()
    ConsoleWrite(@CRLF & "!MOUSE WHEEL DOWN")
    $gMb_wheel_down = 1
EndFunc;MOUSE_WHELLSCROLL_DOWN()

Func MOUSE_WHELLSCROLL_UP()
    ConsoleWrite(@CRLF & "!MOUSE WHEEL UP")
    $gMb_wheel_up = 1
EndFunc;MOUSE_WHELLSCROLL_UP()

Assign those functions to be called on mouse wheel up | down.

_MouseSetOnEvent_RI($MOUSE_WHEELSCROLLUP_EVENT, "MOUSE_WHELLSCROLL_UP", $hGui)
_MouseSetOnEvent_RI($MOUSE_WHEELSCROLLDOWN_EVENT, "MOUSE_WHELLSCROLL_DOWN", $hGui)

Now you can check the variables to test for true.  If true, switch them back off and maybe do some action.

If $gMb_wheel_up = 1 Then
    $gMb_wheel_up = 0
    Exit
EndIf

 

Exactly what I needed.  You are a gentleman and a scholar.

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...