Jump to content

changing button text


derblub
 Share

Recommended Posts

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

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

Link to comment
Share on other sites

  • Moderators

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.

Link to comment
Share on other sites

  • Moderators

:) 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.

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...