Sign in to follow this  
Followers 0
derblub

changing button text

7 posts in this topic

hi - im new to autoit and i got allready a question

how to change the button-text in a loop?

i got a start button - if i click it, it changes the caption to stop - but if i click again, it stays on stop..

can someone help me please?

my code sofar

Dim $buttontext = "start"
$startbutton = GuiCtrlCreateButton ($buttontext,110,50,70,20)
        
        

GuiSetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    If $msg = $startbutton Then
        If $buttontext = "start" Then
       GUICtrlSetData($startbutton, "stop")
       Else
        If $buttontext = "stop" Then
       GUICtrlSetData($startbutton, "start")
        EndIf
        EndIf
    EndIf
WEnd

thx in advance

Share this post


Link to post
Share on other sites



#include <GUIConstants.au3>
Dim $buttontext = "start"
GUICreate("")
$startbutton = GUICtrlCreateButton($buttontext, 110, 50, 70, 20)
GUISetState()
While 1
    $msg = GUIGetMsg()
    If $msg = $GUI_EVENT_CLOSE Then Exit
    If $msg = $startbutton Then
        If GUICtrlRead($startbutton) = "start" Then
            GUICtrlSetData($startbutton, "stop")
        Else
            GUICtrlSetData($startbutton, "start")
        EndIf
    EndIf
WEnd

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

great!!! thx

gui constants and gui itself where allready there, i only forgot to copy them into the code

but with the ctrlread it works flawless now!!

many thx for this fast answer!!

Share this post


Link to post
Share on other sites

Welcome!!

... thats what they pay me for ...lol

8)

BTW: Welcome to the Autoit Forums!


NEWHeader1.png

Share this post


Link to post
Share on other sites

Welcome!!

... thats what they pay me for ...lol

8)

BTW: Welcome to the Autoit Forums!

Over paid or Under worked? :)

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.

Share this post


Link to post
Share on other sites
:) its a bit difficult to learn the syntax - but i think im gonna love autoit for dev :) - a great "little" tool it is! (and looks like a nice community too :P)

Share this post


Link to post
Share on other sites

:) its a bit difficult to learn the syntax - but i think im gonna love autoit for dev :) - a great "little" tool it is! (and looks like a nice community too :P)

The syntax is quite easy actually... a bit more logical than others I've played with IMHO.

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.

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