Jump to content

how to change the start button to stop


Go to solution Solved by JohnOne,

Recommended Posts

hello....i'm beginner

I love to learn to use autoit

simply,how to make script?

when push the start button automatically run notepad then the start button turns into a stop button,

and when the start button changed to stop then i push the button automatically close notepad

post-81604-0-89051300-1377388965_thumb.j change to post-81604-0-97621300-1377389169_thumb.j

 

my script

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("LATIHAN BUTTON", 273, 124, 192, 144)
$START = GUICtrlCreateButton("STOP", 80, 40, 89, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $Msg = GUIGetMsg()
    If $msg=$START Then START()
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func START()
    Run("notepad.exe")
EndFunc

Func STOP()
    WinClose("Untitled - Notepad")
EndFunc
Edited by fikri1979
Link to comment
Share on other sites

here is one example

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $btext[2] = ['Start', 'Stop']
Local $btnflag = 0
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("LATIHAN BUTTON", 273, 124, 192, 144)
$START = GUICtrlCreateButton($btext[0], 80, 40, 89, 33)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
    $Msg = GUIGetMsg()
    If $Msg = $START Then
        START()
    EndIf
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func START()
    $btnflag = Not $btnflag
    GUICtrlSetData($START, $btext[$btnflag])
EndFunc   ;==>START

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Link to comment
Share on other sites

 

here is one example

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $btext[2] = ['Start', 'Stop']
Local $btnflag = 0
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("LATIHAN BUTTON", 273, 124, 192, 144)
$START = GUICtrlCreateButton($btext[0], 80, 40, 89, 33)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
    $Msg = GUIGetMsg()
    If $Msg = $START Then
        START()
    EndIf
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func START()
    $btnflag = Not $btnflag
    GUICtrlSetData($START, $btext[$btnflag])
EndFunc   ;==>START

Thank you very much...

Link to comment
Share on other sites

  • Solution

Here is one way.

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Local $btext[2] = ['Start', 'Stop']
Local $btnflag = 0
Local $pid
#region ### START Koda GUI section ### Form=
$Form1 = GUICreate("LATIHAN BUTTON", 273, 124, 192, 144)
$START = GUICtrlCreateButton($btext[0], 80, 40, 89, 33)
GUISetState(@SW_SHOW)
#endregion ### END Koda GUI section ###

While 1
    $Msg = GUIGetMsg()
    If $Msg = $START Then
        START()
    EndIf
    Switch $Msg
        Case $GUI_EVENT_CLOSE
            Exit
    EndSwitch
WEnd

Func START()
    $btnflag = Not $btnflag
    If Not $btnflag Then
        ProcessClose($pid)
    Else
        $pid = Run("notepad.exe")
    EndIf
    GUICtrlSetData($START, $btext[$btnflag])
EndFunc   ;==>START

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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