Jump to content

Recommended Posts

Posted

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. 

Posted

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

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
×
×
  • Create New...