Sign in to follow this  
Followers 0

Mouse over Label

4 posts in this topic

Hi I've only discoverd AutoIt this week and i must say it is awsome!!!

I'm trying to change the colour of a label when i move my mouse over it.

So far i've got it to work when i click on the label. I need to be able to hover over the label. How do i do this.


$label1=GuiCtrlCreateLabel(@CRLF & "Open File", 40, 40, 360, 40, $SS_SUNKEN )

GuiCtrlSetBkColor(-1, 0xece9d8)


Func Label1Click()

GuiCtrlSetBkColor($label1, 0xFFFFCC)


Thanks in advance :whistle:

Share this post

Link to post
Share on other sites


there is a MouseHover udf in Scripts & Scrapts.

So long,


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post

Link to post
Share on other sites

:whistle: QUALITY!

Thanks for that :)

Share this post

Link to post
Share on other sites

#4 ·  Posted (edited)

#include <guiconstants.au3>
Opt('GUIOnEventMode', 1)
Global $MainLabelColour = 0xECE9D8, $OverLabelColour = 0xFFFFCC, $MouseOver = 1
$MainGUI = GUICreate('Test', 440, 120)
$label1 = GUICtrlCreateLabel(@CRLF & "Open File", 40, 40, 360, 40, $SS_SUNKEN )
GUICtrlSetBkColor(-1, $MainLabelColour)
GUISetOnEvent($GUI_EVENT_CLOSE, '_Exit', $MainGUI)
AdlibEnable("_AdlibManager", 10)

While 1

Func _AdlibManager()
    _LabelOver($MainGUI, $label1)

Func _LabelOver($hMainWnd, $hControl)
    Local $aGetCursor = GUIGetCursorInfo($MainGUI)
    If $MouseOver and $aGetCursor[4] = $hControl Then
        GUICtrlSetBkColor($hControl, $OverLabelColour)
        $MouseOver = 0
    ElseIf Not $MouseOver And Not $aGetCursor[4] = $hControl Then
        GUICtrlSetBkColor($hControl, $MainLabelColour)
        $MouseOver = 1

Func _Exit()
    Exit 0

Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

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