T3HP0wNz0Rrr Posted April 1, 2010 Share Posted April 1, 2010 Hey all, I have a new question: I want my bot to show the total time he's running. I got @MIN, @SEC and @HOUR declared in the start of the program. Now, i want my bot to update every second the time it is, and display the total time it is running for. Example: Started at 21:24:36, and now it is 21:34:36; he must display: "Running for: 0:10:0" or something like that. If someone can give me the code, THANKS! Link to comment Share on other sites More sharing options...
KaFu Posted April 1, 2010 Share Posted April 1, 2010 Help-File example for the _TicksToTime() UDF. expandcollapse popup; *** Demo to show a timer window #include <GUIConstantsEx.au3> #include <Date.au3> Opt("TrayIconDebug", 1) Opt("MustDeclareVars", 1) Global $timer, $Secs, $Mins, $Hour, $Time _Main() Func _Main() ;Create GUI GUICreate("Timer", 120, 50) GUICtrlCreateLabel("00:00:00", 10, 10) GUISetState() ;Start timer $timer = TimerInit() AdlibRegister("Timer", 50) ; While 1 ;FileWriteLine("debug.log",@min & ":" & @sec & " ==> before") Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit EndSwitch ;FileWriteLine("debug.log",@min & ":" & @sec & " ==> after") WEnd EndFunc ;==>_Main ; Func Timer() _TicksToTime(Int(TimerDiff($timer)), $Hour, $Mins, $Secs) Local $sTime = $Time ; save current time to be able to test and avoid flicker.. $Time = StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs) If $sTime <> $Time Then ControlSetText("Timer", "", "Static1", $Time) EndFunc ;==>Timer OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
T3HP0wNz0Rrr Posted April 1, 2010 Author Share Posted April 1, 2010 Thanks! Works like a charm. But how do i multi-process this? I want to let it tickalong then my bot runs without needing to call the other Timer() func? Link to comment Share on other sites More sharing options...
KaFu Posted April 1, 2010 Share Posted April 1, 2010 Just fill the while loop with your desired code, the adlibregister will kick in every 1000ms automatically. OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
T3HP0wNz0Rrr Posted April 1, 2010 Author Share Posted April 1, 2010 You're a genius! 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