Jump to content

Recommended Posts

Posted (edited)

Hi,

How can I detect when mouse(cursor) is over a control? I know that GuiGetCursorInfo can achieve this but how can I use it with cases?

#include <GuiConstants.au3>

GuiCreate("Touch me!", 392, 316,-1, -1)

$Button_0 = GuiCtrlCreateButton("", 125, 100, 100, 100, $BS_BITMAP)

Guisetstate()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    EndSelect
WEnd
Exit
Edited by J0ker
Posted

I'm not sure exactly you meant by "use with cases", but this is one way I'd trip off a mouse over a button event using a While 1/WEnd loop

#include <GuiConstants.au3>
 
$gui = GuiCreate("Touch me!", 392, 316,-1, -1)

$Button_0 = GuiCtrlCreateButton("", 125, 100, 100, 100, $BS_BITMAP)

Guisetstate()

While 1
    If WinActive($gui) Then
        $ggci = GUIGetCursorInfo($gui)
        If $ggci[4] = $Button_0 Then
            ;; Mouse is over button_0, do stuff
            ToolTip("mouse over button")
        Else
            ;; Mouse has left button_0
            ToolTip("")
        EndIf
    EndIf   
    $msg = GuiGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
WEnd
Exit

Cheers

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
  • Recently Browsing   0 members

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