Jump to content
Sign in to follow this  
freebsdx

Event trigger with middle mouse button scrolling up/down(back/forward), how?

Recommended Posts

freebsdx

Greetings everyone. I am a newbie of this powerful wand.

My purpose, for simplicity, is to customize the event when I scroll the middle mouse button. 

For example, when I scroll the middle mouse button up (forward?), my script is expected to send "A" to the notepad, and when I scroll the middle mouse button down(backward?), my script is excepted to send "B" to the notepad. 

After googling for some time, I can't find the answer to my question. All tricks I got are the opposite things: pressing the key “A” to scroll the middle mouse button up and “B” to scroll the middle mouse button down.

Is any guru here willing to provide a hint? Your help is greatly appreciated. Thank you in advance. 

Share this post


Link to post
Share on other sites
mikell

Scroll the middle mouse button, do you mean scroll the wheel ?

Share this post


Link to post
Share on other sites
freebsdx

Scroll the middle mouse button, do you mean scroll the wheel ?

Exactly.

Share this post


Link to post
Share on other sites
mikell

Ok, so here is an example which will be easy to arrange for your script

Hover the gui and scroll the mouse wheel

#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

$gui = GUICreate("test", 120, 100)
GUISetBkColor(0x000000)
GuiSetFont(48, 600, 0, "Arial")
$label = GUICtrlCreateLabel("0", 10, 10, 85, 70, 2)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xff0000)
GUISetState()  

GUIRegisterMsg($WM_MOUSEWHEEL, "WM_MOUSEWHEEL")
$n = 0

While 1
    $msg = GuiGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
Wend

Func WM_MOUSEWHEEL($hWnd,$iMsg, $iwParam, $ilParam)
    #forceref $hwnd, $iMsg, $ilParam
    Local $a = GUIGetCursorInfo($gui)
    If $a[4] = $label Then 
        Local $iDelta = BitShift($iwParam, 16) 
        If $iDelta > 0 Then $n += 1
        If $iDelta < 0 Then $n -= 1
        GUICtrlSetData($label, $n)
    EndIf
  Return $GUI_RUNDEFMSG
EndFunc

Share this post


Link to post
Share on other sites
freebsdx

My problem is solved. Thank you!!! :sorcerer: 

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
Sign in to follow this  

×