MattHiggs

(solved) Extend use of "_IsPressed" function

4 posts in this topic

#1 ·  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

Share this post


Link to post
Share on other sites



#2 ·  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
1 person likes this

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


Link to post
Share on other sites

#3 ·  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.

Share this post


Link to post
Share on other sites

#4 ·  Posted

Quote

You are a gentleman and a scholar.

I try so hard.

2 people like this

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


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