mini Posted April 18, 2010 Posted April 18, 2010 Hello guys. I found this Code that countdown min, but when it rich 0, it continues to countdown to -1,-2 and sow on... How can i change the code to restart counting back from 1min?? I didn't made the code and i don't understand it very well. I'm trying to put it on my GUI because my GUI have some Delayer timer. Here's the code i found: #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 122, 42, 438, 156) $Label1 = GUICtrlCreateLabel("15:00", 8, 8, 43, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $time=TimerInit() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $new = TimerDiff ($time) $new = (1*60*1000)-$new $seconds = Round ($new/1000) $newMin = Floor ($seconds/60) $newSec = Mod ($seconds, 60) If $newSec < 10 Then $newSec = "0"&$newSec GUICtrlSetData ($Label1, $newMin&":"&$newSec) WEnd Thanks for all replays and help. [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.
enaiman Posted April 18, 2010 Posted April 18, 2010 Here you go: #include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("AForm1", 122, 42, 438, 156) $Label1 = GUICtrlCreateLabel("15:00", 8, 8, 43, 17) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### $time=TimerInit() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit EndSwitch $new = TimerDiff ($time) $new = (1*60*1000)-$new $seconds = Round ($new/1000) $newMin = Floor ($seconds/60) $newSec = Mod ($seconds, 60) If $newMin = 0 And $newSec = 0 Then $time=TimerInit() Else If $newSec < 10 Then $newSec = "0"&$newSec GUICtrlSetData ($Label1, $newMin&":"&$newSec) EndIf WEnd SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script wannabe "Unbeatable" Tic-Tac-Toe Paper-Scissor-Rock ... try to beat it anyway :)
mini Posted April 18, 2010 Author Posted April 18, 2010 (edited) wow nice bro, thanks very much.... :) But i try to put it on my code, and it can read my Delayer time, but it stops to work after 3, 4 sec's... I don't know how to work around it, sow i think I'm not going to use it... Unless your up to make it work on my Gui. If your interested on trying to make it, her's my code: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon= #AutoIt3Wrapper_Outfile=Sbot Training Swapper.exe #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI **** #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) TraySetOnEvent($TRAY_EVENT_PRIMARYUP, "On_Show") ;<================================================================================== #Region TrayCreateItem("") $StartItem = TrayCreateItem("Start") $StopItem = TrayCreateItem("Stop") TrayCreateItem("") $RestoreSbotItem = TrayCreateItem("Show Sbot") $HideSbotItem = TrayCreateItem("Hide Sbot") TrayCreateItem("") $RestoreSROItem = TrayCreateItem("Show SRO") $HideSROItem = TrayCreateItem("Hide SRO") TrayCreateItem("") $RestoreItem = TrayCreateItem("Restore Swapper") $HideItem = TrayCreateItem("Hide Swapper") TrayCreateItem("") $ExitItem = TrayCreateItem("Exit") TrayCreateItem("") #EndRegion ;<================================================================================== #Region $TrayStartItem = TrayItemSetOnEvent($StartItem, "_Check4Start") $TrayStopItem = TrayItemSetOnEvent($StopItem, "_Check4Stop") $TrayRestoreSbotItem = TrayItemSetOnEvent($RestoreSbotItem, "_Check4ShowSbot") $TrayHideSbotItem = TrayItemSetOnEvent($HideSbotItem, "_Check4HideSbot") $TrayRestoreSROItem = TrayItemSetOnEvent($RestoreSROItem, "_Check4ShowSRO") $TrayHideSROItem = TrayItemSetOnEvent($HideSROItem, "_Check4HideSRO") $TrayRestoreItem = TrayItemSetOnEvent($RestoreItem, "_Check4Restore") $TrayHideItem = TrayItemSetOnEvent($HideItem, "_Check4Hide") $TrayExitItem = TrayItemSetOnEvent($ExitItem, "_Check4CLOSEClicked") #EndRegion ;~ <================================================================================== #Region $sINI = @ScriptDir & "\" $Form1 = GUICreate("Sbot Training Swapper", 373, 305) $Button_Start = GUICtrlCreateButton("Start", 75, 270, 50, 25) $Button_Stop = GUICtrlCreateButton("Stop", 130, 270, 50, 25) $training1 = GUICtrlCreateCheckbox("Training place 1", 16, 16, 97, 17) $training2 = GUICtrlCreateCheckbox(" Training place 2", 136, 16, 97, 17) $training3 = GUICtrlCreateCheckbox("Training place 3", 264, 16, 97, 17) $TimeLabel1 = GUICtrlCreateLabel("", 300, 273, 60, 21) ;~ < ;~ $KS1 = GUICtrlCreateCheckbox("Do Kill Still", 10, 170, 97, 17) ;~ $StayTillDead1 = GUICtrlCreateCheckbox(" Stay Till Mob Dead", 10, 190, 110, 17) ;~ $KS2 = GUICtrlCreateCheckbox("Do Kill Still", 130, 170, 97, 17) ;~ $StayTillDead2 = GUICtrlCreateCheckbox(" Stay Till Mob Dead", 130, 190, 110, 17) ;~ $KS3 = GUICtrlCreateCheckbox("Do Kill Still", 260, 170, 97, 17) ;~ $StayTillDead3 = GUICtrlCreateCheckbox(" Stay Till Mob Dead", 260, 190, 110, 17) ;~ < $Input1A = GUICtrlCreateInput("", 8, 48, 105, 21) $Input2A = GUICtrlCreateInput("", 8, 78, 105, 21) $Input3A = GUICtrlCreateInput("", 8, 108, 105, 21) $Input4A = GUICtrlCreateInput("", 8, 138, 105, 21) $Input1B = GUICtrlCreateInput("", 136, 48, 105, 21) $Input2B = GUICtrlCreateInput("", 136, 78, 105, 21) $Input3B = GUICtrlCreateInput("", 136, 108, 105, 21) $Input4B = GUICtrlCreateInput("", 136, 138, 105, 21) $Input1C = GUICtrlCreateInput("", 264, 48, 105, 21) $Input2C = GUICtrlCreateInput("", 264, 78, 105, 21) $Input3C = GUICtrlCreateInput("", 264, 108, 105, 21) $Input4C = GUICtrlCreateInput("", 264, 138, 105, 21) $Input_Sbot_Name = GUICtrlCreateInput("", 70, 220, 100, 21) $Label1 = GUICtrlCreateLabel("Sbot Name", 13, 225, 57, 17) $Input_SRO_Name = GUICtrlCreateInput("", 250, 220, 105, 21) $Label3 = GUICtrlCreateLabel("SRO Name", 180, 225, 57, 17) $Label2 = GUICtrlCreateLabel("Time to switch traning place, time in min, 60m = 1H", 15, 245, 289, 17) $Sleep_Time = GUICtrlCreateInput("", 250, 270, 40, 21) #EndRegion ;<================================================================================== #Region $iRead = GUICtrlSetData($Input1A, IniRead("Sbot Training Swapper.ini", "TrainingA", "$Input1A", "Coor. X")) $iRead = GUICtrlSetData($Input2A, IniRead("Sbot Training Swapper.ini", "TrainingA", "$Input2A", "Coor. Y")) $iRead = GUICtrlSetData($Input3A, IniRead("Sbot Training Swapper.ini", "TrainingA", "$Input3A", "Coor. Z")) $iRead = GUICtrlSetData($Input4A, IniRead("Sbot Training Swapper.ini", "TrainingA", "$Input4A", "Range")) $iRead = GUICtrlSetData($Input1B, IniRead("Sbot Training Swapper.ini", "TrainingB", "$Input1B", "Coor. X")) $iRead = GUICtrlSetData($Input2B, IniRead("Sbot Training Swapper.ini", "TrainingB", "$Input2B", "Coor. Y")) $iRead = GUICtrlSetData($Input3B, IniRead("Sbot Training Swapper.ini", "TrainingB", "$Input3B", "Coor. Z")) $iRead = GUICtrlSetData($Input4B, IniRead("Sbot Training Swapper.ini", "TrainingB", "$Input4B", "Range")) $iRead = GUICtrlSetData($Input1C, IniRead("Sbot Training Swapper.ini", "TrainingC", "$Input1C", "Coor. X")) $iRead = GUICtrlSetData($Input2C, IniRead("Sbot Training Swapper.ini", "TrainingC", "$Input2C", "Coor. Y")) $iRead = GUICtrlSetData($Input3C, IniRead("Sbot Training Swapper.ini", "TrainingC", "$Input3C", "Coor. Z")) $iRead = GUICtrlSetData($Input4C, IniRead("Sbot Training Swapper.ini", "TrainingC", "$Input4C", "Range")) $iRead = GUICtrlSetData($Input_Sbot_Name, IniRead("Sbot Training Swapper.ini", "$Input_Sbot_Name", "$Input_Sbot_Name", "[X" & "X] SBot v1.66 (C)2008,2009 by bot-cave.net")) $iRead = GUICtrlSetData($Input_SRO_Name, IniRead("Sbot Training Swapper.ini", "$Input_SRO_Name", "$Input_SRO_Name", "SRO_Client [X" & "X]")) $iRead = GUICtrlSetData($Sleep_Time, IniRead("Sbot Training Swapper.ini", "$Sleep_Time", "$Sleep_Time", "60")) #EndRegion ;<================================================================================== ;~ ControlCommand ( GUICtrlRead($Input_Sbot_Name), "text", controlID, "IsChecked" ) GUISetState(@SW_SHOW) ;<================================================================================== Dim $Start = 0 While 1 ;Code Switch GUIGetMsg() Case -3 _Check4CLOSEClicked() Case $GUI_EVENT_MINIMIZE GUISetState(@SW_HIDE, $Form1) Case $Button_Stop _Check4Stop() Case $Button_Start _Check4Start() EndSwitch If $Start = 1 And GUICtrlRead($training1) = 1 Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ConsoleWrite("Trg1" & @CRLF) ;#cs ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{DEL 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{BS 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", GUICtrlRead($Input1A)) ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{DEL 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{BS 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", GUICtrlRead($Input2A)) ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{DEL 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{BS 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", GUICtrlRead($Input3A)) ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{DEL 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{BS 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", GUICtrlRead($Input4A)) WinSetState(GUICtrlRead($Input_Sbot_Name), "", @SW_MINIMIZE) WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Save settings", "[CLASS:Button; INSTANCE:192]", "{SPACE 5}")) WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Stop training", "[CLASS:Button; INSTANCE:195]", "{SPACE 5}")) WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Start training", "[CLASS:Button; INSTANCE:194]", "{SPACE 5}")) WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Start training", "[CLASS:Button; INSTANCE:191]", "{SPACE 5}")) WinSetState(GUICtrlRead($Input_Sbot_Name), "", @SW_HIDE) ;#ce _Delayer() EndIf If $Start = 1 And GUICtrlRead($training2) = 1 Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ConsoleWrite("Trg2" & @CRLF) ;#cs ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{DEL 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{BS 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", GUICtrlRead($Input1B)) ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{DEL 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{BS 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", GUICtrlRead($Input2B)) ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{DEL 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{BS 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", GUICtrlRead($Input3B)) ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{DEL 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{BS 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", GUICtrlRead($Input4B)) WinSetState(GUICtrlRead($Input_Sbot_Name), "", @SW_MINIMIZE) WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Save settings", "[CLASS:Button; INSTANCE:192]", "{SPACE 5}")) WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Stop training", "[CLASS:Button; INSTANCE:195]", "{SPACE 5}")) WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Start training", "[CLASS:Button; INSTANCE:194]", "{SPACE 5}")) WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Start training", "[CLASS:Button; INSTANCE:191]", "{SPACE 5}")) WinSetState(GUICtrlRead($Input_Sbot_Name), "", @SW_HIDE) ;#ce _Delayer() EndIf If $Start = 1 And GUICtrlRead($training3) = 1 Then ; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ConsoleWrite("Trg3" & @CRLF) ;#cs ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{DEL 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", "{BS 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:40]", GUICtrlRead($Input1C)) ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{DEL 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", "{BS 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:42]", GUICtrlRead($Input2C)) ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{DEL 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", "{BS 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:43]", GUICtrlRead($Input3C)) ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{DEL 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", "{BS 10}") ControlSend(GUICtrlRead($Input_Sbot_Name), "", "[CLASS:Edit; INSTANCE:41]", GUICtrlRead($Input4C)) WinSetState(GUICtrlRead($Input_Sbot_Name), "", @SW_MINIMIZE) WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Save settings", "[CLASS:Button; INSTANCE:192]", "{SPACE 5}")) WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Stop training", "[CLASS:Button; INSTANCE:195]", "{SPACE 5}")) WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Start training", "[CLASS:Button; INSTANCE:194]", "{SPACE 5}")) WinActivate(ControlSend(GUICtrlRead($Input_Sbot_Name), "Start training", "[CLASS:Button; INSTANCE:191]", "{SPACE 5}")) WinSetState(GUICtrlRead($Input_Sbot_Name), "", @SW_HIDE) ;#ce _Delayer() EndIf WEnd ;<================================================================================== Func _Check4Restore() WinSetState("Sbot Training Swapper", "", @SW_MINIMIZE) EndFunc ;==>_Check4Restore ;<================================================================================== Func _Check4Hide() WinSetState("Sbot Training Swapper", "", @SW_HIDE) EndFunc ;==>_Check4Hide ;<================================================================================== Func _Delayer() $iBegin = 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($iBegin) > GUICtrlRead($Sleep_Time) * 60000 ; Check if 5 secs have elapsed EndFunc ;==>_Delayer ;<================================================================================== Func _Check4HideSbot() WinSetState(GUICtrlRead($Input_Sbot_Name), "", @SW_HIDE) EndFunc ;==>_Check4HideSbot ;<================================================================================== Func _Check4ShowSbot() WinSetState(GUICtrlRead($Input_Sbot_Name), "", @SW_MINIMIZE) EndFunc ;==>_Check4ShowSbot ;<================================================================================== Func _Check4HideSRO() WinSetState(GUICtrlRead($Input_SRO_Name), "", @SW_HIDE) EndFunc ;==>_Check4HideSRO ;<================================================================================== Func _Check4ShowSRO() WinSetState(GUICtrlRead($Input_SRO_Name), "", @SW_RESTORE) EndFunc ;==>_Check4ShowSRO ;<================================================================================== Func _Check4Start() $Start = 1 TrayTip("", "Started", 3, 0) #region IniWrite("Sbot Training Swapper.ini", "TrainingA", "$Input1A", GUICtrlRead($Input1A)) IniWrite("Sbot Training Swapper.ini", "TrainingA", "$Input2A", GUICtrlRead($Input2A)) IniWrite("Sbot Training Swapper.ini", "TrainingA", "$Input3A", GUICtrlRead($Input3A)) IniWrite("Sbot Training Swapper.ini", "TrainingA", "$Input4A", GUICtrlRead($Input4A)) IniWrite("Sbot Training Swapper.ini", "TrainingB", "$Input1B", GUICtrlRead($Input1B)) IniWrite("Sbot Training Swapper.ini", "TrainingB", "$Input2B", GUICtrlRead($Input2B)) IniWrite("Sbot Training Swapper.ini", "TrainingB", "$Input3B", GUICtrlRead($Input3B)) IniWrite("Sbot Training Swapper.ini", "TrainingB", "$Input4B", GUICtrlRead($Input4B)) IniWrite("Sbot Training Swapper.ini", "TrainingC", "$Input1C", GUICtrlRead($Input1C)) IniWrite("Sbot Training Swapper.ini", "TrainingC", "$Input2C", GUICtrlRead($Input2C)) IniWrite("Sbot Training Swapper.ini", "TrainingC", "$Input3C", GUICtrlRead($Input3C)) IniWrite("Sbot Training Swapper.ini", "TrainingC", "$Input4C", GUICtrlRead($Input4C)) IniWrite("Sbot Training Swapper.ini", "$Input_Sbot_Name", "$Input_Sbot_Name", GUICtrlRead($Input_Sbot_Name)) IniWrite("Sbot Training Swapper.ini", "$Input_SRO_Name", "$Input_SRO_Name", GUICtrlRead($Input_SRO_Name)) IniWrite("Sbot Training Swapper.ini", "$Sleep_Time", "$Sleep_Time", GUICtrlRead($Sleep_Time)) EndFunc ;==>_Check4Start ;<================================================================================== Func _Check4Stop() $Start = 0 TrayTip("", "Stopped", 3, 0) EndFunc ;==>_Check4Stop ;<================================================================================== Func _Check4CLOSEClicked();Exit Opt("WinTitleMatchMode", 2) ; Match substring WinSetTrans("Sbot Training Swapper", "", 0) $answer = MsgBox(36, "Warning", "Close??", 8) WinSetTrans("Sbot Training Swapper", "", 255) If $answer = 6 Then WinSetState(GUICtrlRead($Input_Sbot_Name), "", @SW_MINIMIZE) Exit EndIf EndFunc ;==>_Check4CLOSEClicked ;<================================================================================== Func On_Show() GUISetState(@SW_SHOW, $Form1) EndFunc ;==>On_Show ;<================================================================================== Edited April 19, 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.
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