Sign in to follow this  
Followers 0
EKY32

~ Is it possible to detect the mouse whee move? (SOLVED)

7 posts in this topic

#1 ·  Posted (edited)

Can i run a command when the mouse wheel moves?

Like using GuiCtrlSetOnEvent.. but detecting the mousewheel move.

Thank you.

Edited by EKY32

[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Share this post


Link to post
Share on other sites



Yes, try this example:

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

_Example()

; _Example
Func _Example()
    GUICreate("My GUI", 640, 480, 50, 50) ; will create a dialog box that when displayed is centered

    GUIRegisterMsg($WM_MOUSEWHEEL, "_WM_MOUSEWHEEL")

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $GUI_EVENT_PRIMARYDOWN
                Sleep(250)
                ToolTip("")
                WinClose("[CLASS:Notepad]", "")
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>_Example

Func _WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)

    Local $iMPos = MouseGetPos()

    ToolTip("Mouse wheel is detected!" & @CRLF & @CRLF & 'Click in the "My GUI" to return...', $iMPos[0], $iMPos[1], "Test", 1, 3)

    Run("Notepad.exe")

    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_MOUSEWHEEL

Regards,

João Carlos.

1 person likes this

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites

Oh Mr.JScript, you are killing me with your kindness Posted Image

Thank you again very much, another flower to your score :]


[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Very useful demonstration. I am learning neat concepts from this design. Thank you JScript.

I never knew this, $GUI_EVENT_PRIMARYDOWN

Edited by Xandy

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

Share this post


Link to post
Share on other sites

Mr. JScript:

Is it possible to know if the wheel is up or down?

In fact i want to switch between tab controls with mouse wheel, so i need to detect if it's wheel up or down.

Thank toy.


[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

Yes, in the same example with little modification:

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

_Example()

; _Example
Func _Example()
    GUICreate("My GUI", 640, 480, 50, 50) ; will create a dialog box that when displayed is centered

    GUIRegisterMsg($WM_MOUSEWHEEL, "_WM_MOUSEWHEEL")

    GUISetState(@SW_SHOW) ; will display an empty dialog box

    ; Run the GUI until the dialog is closed
    While 1
        Switch GUIGetMsg()
            Case $GUI_EVENT_CLOSE
                Exit
            Case $GUI_EVENT_PRIMARYDOWN
                Sleep(250)
                ToolTip("")
        EndSwitch
    WEnd
    GUIDelete()
EndFunc   ;==>_Example

Func _WM_MOUSEWHEEL($hWnd, $iMsg, $wParam, $lParam)
    Local $iMPos = MouseGetPos()

    Switch $wParam
        Case 0x00780000
            ToolTip("Mouse wheel UP is detected!" & @CRLF & @CRLF & 'Click in the "My GUI" to return...', $iMPos[0], $iMPos[1], "Wheel UP", 1, 3)
        Case 0xFF880000
            ToolTip("Mouse wheel Down is detected!" & @CRLF & @CRLF & 'Click in the "My GUI" to return...', $iMPos[0], $iMPos[1], "Wheel Down", 1, 3)
    EndSwitch

    Return $GUI_RUNDEFMSG
EndFunc   ;==>_WM_MOUSEWHEEL

Regards,

João Carlos.

Edited by JScript
1 person likes this

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

somewh10.png

dropbo10.pngDownload Dropbox - Simplify your life!
Your virtual HD wherever you go, anywhere!

Share this post


Link to post
Share on other sites

Ah! you are really embarrassing me Posted Image

Thank you very much!!


[font="'trebuchet ms', helvetica, sans-serif;"]Please mark the answer of your question if you found it.[/font]

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  
Followers 0