mini Posted April 21, 2010 Posted April 21, 2010 (edited) Hello guys, yesterday I found a GUI that change the text on the Start Button and it have a "While" and some "Func" to do. Here's a Thread replayed from M23 http://www.autoitscript.com/forum/index.php?showtopic=103733&view=findpost&p=735761 And I'm trying to make my GUI to work like that one... Or to change the the button name, here's a test GUI: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Constants.au3> ;<================================================================================== Opt("TrayMenuMode", 1) ; Default tray menu items (Script Paused/Exit) will not be shown. Opt("TrayOnEventMode", 1) ;~ Opt('MustDeclareVars', 1) TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "On_Show") ;~ <================================================================================== Global $Action_Button ;~ <================================================================================== $Form1 = GUICreate("Swapper", 373, 305) $Action_Button = GUICtrlCreateButton("Start", 75, 270, 50, 25) ;~ <================================================================================== $traget1 = GUICtrlCreateCheckbox("", 10, 16, 14, 20) $tragetInput1 = GUICtrlCreateInput("Target 1", 30, 16, 83, 20) ;~ <================================================================================== $traget2 = GUICtrlCreateCheckbox("", 136, 16, 14, 20) $tragetInput2 = GUICtrlCreateInput("Target 2", 158, 16, 83, 20) ;~ <================================================================================== $traget3 = GUICtrlCreateCheckbox("", 264, 16, 14, 20) $tragetInput3 = GUICtrlCreateInput("Target 3", 285, 16, 83, 20) ;~ <================================================================================== $Sleep_Time = GUICtrlCreateInput("1", 250, 270, 40, 21) ;~ <================================================================================== GUISetState(@SW_SHOW) ;~ <================================================================================== Dim $Action_Button = 0 While 1 ;Code Switch GUIGetMsg() Case -3 _Check4CLOSEClicked() Case $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE, $Form1) Case $Action_Button _Action() EndSwitch WEnd ;~ <================================================================================== Func _Action() Local $iBegin Switch GUICtrlRead($Action_Button) Case "Start" GUICtrlSetData($Action_Button, "Stop") ; <<<<<<<<<<<<<<<<<<<<<<<<<<<< Your original script starts here While 1 If Action_Check() Then ContinueCase ; <<<<<<<<<<< If Stop button pressed, move to that Case If $Action_Button = 1 And GUICtrlRead($traget1) = 1 Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ConsoleWrite("Trg1" & @CRLF) _Delayer() EndIf If $Action_Button = 1 And GUICtrlRead($traget2) = 1 Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ConsoleWrite("Trg2" & @CRLF) _Delayer() EndIf If $Action_Button = 1 And GUICtrlRead($traget3) = 1 Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ConsoleWrite("Trg3" & @CRLF) _Delayer() EndIf If Action_Check() Then ContinueCase ; <<<<<<<<<<< If Stop button pressed, move to that Case WEnd Case "Stop" GUICtrlSetData($Action_Button, "Start") EndSwitch EndFunc ;==>_Action ;~ <================================================================================== Func Action_Check() Switch GUIGetMsg() Case $Action_Button Return 1 ; <<<<<<<<<<<<<<<< The Stop button was pressed, so return a flag EndSwitch Return 0 ; <<<<<<<<<<<<<<<<<<<<<<<<< Nothing pressed so ensure no flag returned EndFunc ;==>Action_Check ;~ <================================================================================== Func _Delayer() $idBegin = TimerInit() ; Get a timestamp Do ; Loop until Switch GUIGetMsg() ; Check the valid events (no point in looking for Start as we are already running!) Case -3 Exit ;~ Case $Button_Stop ;~ _Check4Stop() ExitLoop EndSwitch Until TimerDiff($idBegin) > GUICtrlRead($Sleep_Time) * 60000 ; Check if 5 secs have elapsed EndFunc ;==>_Delayer ;~ <================================================================================== Func _Check4CLOSEClicked();Exit Opt("WinTitleMatchMode", 2) ; Match substring WinSetTrans("Swapper", "", 0) $answer = MsgBox(36, "Warning", "Close??", 8) WinSetTrans("Swapper", "", 255) If $answer = 6 Then Exit EndIf EndFunc ;==>_Check4CLOSEClicked ;~ <================================================================================== Func On_Show() GUISetState(@SW_SHOW, $Form1) EndFunc ;==>On_Show ;~ <================================================================================== If you guys want my Original GUI, just ask please. Thank you for all replays. Edited April 22, 2010 by mini [size="4"]My first work[/size], it checks if one prograrm is running and if not it closes all necessery windows and run them again.[size="4"]My second work[/size], Script Function: It saves a Client Info and creates a INI file for all clients with all the info.[size="4"]My third work[/size], Script Function: It change some INFO on a working program, every X min configured.
mini Posted April 22, 2010 Author Posted April 22, 2010 WOW I'm getting a BRAIN I did it all alone Thanks for .... (reading this thread) hehehe [size="4"]My first work[/size], it checks if one prograrm is running and if not it closes all necessery windows and run them again.[size="4"]My second work[/size], Script Function: It saves a Client Info and creates a INI file for all clients with all the info.[size="4"]My third work[/size], Script Function: It change some INFO on a working program, every X min configured.
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