Jump to content

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


EKY32
 Share

Recommended Posts

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]

Link to comment
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.

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!

Link to comment
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]

Link to comment
Share on other sites

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

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!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...