fikri1979 Posted August 25, 2013 Share Posted August 25, 2013 (edited) 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 change to 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 August 25, 2013 by fikri1979 Link to comment Share on other sites More sharing options...
JohnOne Posted August 25, 2013 Share Posted August 25, 2013 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 More sharing options...
fikri1979 Posted August 25, 2013 Author Share Posted August 25, 2013 (edited) Spend more time on the helpfile, you won't ask crap questions on the forum. sorry for my weakness and language errors, because I am not fluent english Thank you for your attention Edited August 25, 2013 by fikri1979 Link to comment Share on other sites More sharing options...
fikri1979 Posted August 25, 2013 Author Share Posted August 25, 2013 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 More sharing options...
fikri1979 Posted August 25, 2013 Author Share Posted August 25, 2013 Thank you very much... once again.. when it was changed to stop button, how to close the program using the change button? Func START() $btnflag = Not $btnflag GUICtrlSetData($START, $btext[$btnflag]) Run("notepad.exe") EndFunc ;==>START Func STOP() WinClose("[CLASS:Notepad]", "") EndFunc ;==>STOP Link to comment Share on other sites More sharing options...
Solution JohnOne Posted August 25, 2013 Solution Share Posted August 25, 2013 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 Gianni and fikri1979 2 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 More sharing options...
FireFox Posted August 25, 2013 Share Posted August 25, 2013 (edited) @fikri1979 I would like to apologize for the tone of my first reply, I was a in bad mood. I didn't mean to attack you of course; see ya on the forum Br, FireFox. Edited August 25, 2013 by FireFox fikri1979 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now