Sign in to follow this  
Followers 0
behdadsoft

Mouse Over change Label

14 posts in this topic

#1 ·  Posted (edited)

Hi.

I create a label in my GIU and I want when mouse over on the button change label text. how can do it?

Thanks.

Edited by behdadsoft

Share this post


Link to post
Share on other sites



Hi,

check out GUIGetCursorInfo().

Use it in a function with AdLibRegister that compares the ID of your control to $array[4] you get from GUIGetCursorInfo every 100 ms.

Share this post


Link to post
Share on other sites

thanks but what is adlib?

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Thanks

Edited by behdadsoft

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

there is a problem when I use Switch---Case for Check my GUIGetCursorInfo() value give me an error when click on Desktop.

Func CheckGUI_ID ()
     Local $GUI_ID = GUIGetCursorInfo()

   Switch $GUI_ID [4]
            Case 0
               GUICtrlSetData ($GUILabel, "Ready")
            Case 3
               GUICtrlSetData ($GUILabel, "My Computer")
   EndSwitch

   EndFunc

Please Guide Me.

Edited by behdadsoft

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

use Case Else don't fix problem. I think Problem is relate to [4] at $GUI_ID [4]. because when I remove [4] make fix the Problem but switch---Case don't work. :(

Edited by behdadsoft

Share this post


Link to post
Share on other sites

I used GUIGetCursorInfo($GUI) and make fix problem relate to close my GUI when click on Desktop. but when I compile My Script and run it Give me below error:

Error: Subscript used on non-accessible variable.

I think this error is relate to $GUI_ID [4].

Share this post


Link to post
Share on other sites

Post your latest code :)


Snips & Scripts


My Snips: graphCPUTemp ~ getENVvars
My Scripts: Short-Order Encrypter - message and file encryption V1.6.1 ~ AuPad - Notepad written entirely in AutoIt V1.9.4

Feel free to use any of my code for your own use.                                                                                                                                                           Forum FAQ

 

Share this post


Link to post
Share on other sites

error handling required:

Func CheckGUI_ID ()

    Local $GUI_ID = GUIGetCursorInfo($GUI)
    If Not @error Then
        Switch $GUI_ID [4]
            Case 3
            GUICtrlSetData ($GUILabel, "Hello")
            Case 4
            GUICtrlSetData ($GUILabel, "Bye")
            Case Else
            GUICtrlSetData ($GUILabel, $DefaultLabelText)
        EndSwitch
    EndIf

EndFunc

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

 

error handling required:

Func CheckGUI_ID ()

    Local $GUI_ID = GUIGetCursorInfo($GUI)

    If Not @error Then

        Switch $GUI_ID [4]

            Case 3

            GUICtrlSetData ($GUILabel, "Hello")

            Case 4

            GUICtrlSetData ($GUILabel, "Bye")

            Case Else

            GUICtrlSetData ($GUILabel, $DefaultLabelText)

        EndSwitch

    EndIf

EndFunc

 

 

Thanks, work fine. :)

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

behdadsoft,

A more flexible approach...

#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>

#AutoIt3Wrapper_Add_Constants=n

local $gui010   =   guicreate('')
local $aSize    =   wingetclientsize($gui010)
local $lbl010   =   guictrlcreatelabel('',0,020,$aSize[0],50,$ss_sunken)
local $lbl020   =   guictrlcreatelabel('',0,100,$aSize[0],50,$ss_sunken)
                    guisetstate()

$aCSR = GUIGetCursorInfo($gui010)

while 1

    switch guigetmsg()
        case $gui_event_close
            Exit
    EndSwitch

    _on_hover($lbl010)
    _on_hover($lbl020)

WEnd

func _on_hover($ctlid)

    local static $last_ctlid

    switch GUIGetCursorInfo($gui010)[4]
        case $ctlid
            GUICtrlSetBkColor($ctlid,0xff0000)
            $last_ctlid = $ctlid
        case else
            if $last_ctlid = $ctlid then
                GUICtrlSetBkColor($ctlid,0x550000)
                $last_ctlid = 0
            endif
    endswitch

endfunc

kylomas

edit: spelling

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

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