Indiaum Posted March 22, 2015 Share Posted March 22, 2015 Hi guys, I'm new to AutoIt and i need a explanation on Timers, because something is happening and i can't understand why. I need a timer, so i did: Global $TIMER = 0 Global $TIMERDIFF = 0 Main() Func Main() While 1 $TIMERDIFF = Round(TimerDiff($TIMER) / 1000, 1) ToolTip($TIMERDIFF, 100, 100, "Info", 1, 1) WEnd WEnd EndFunc Link to comment Share on other sites More sharing options...
UEZ Posted March 22, 2015 Share Posted March 22, 2015 You missed to set Global $TIMER = TimerInit() Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
water Posted March 22, 2015 Share Posted March 22, 2015 Welcome to AutoIt and the forum! You first need to initialize the timer using TimerInit. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Indiaum Posted March 22, 2015 Author Share Posted March 22, 2015 Thank you very much for the extremely fast response. It was intentional, i thought that i could keep a timer stopped, and only use the TimerInit() to start it in a specific moment. After the TimerInit(), is it possible to stop it? Link to comment Share on other sites More sharing options...
JohnOne Posted March 22, 2015 Share Posted March 22, 2015 TimerInit / TimerDiff are not something that runs, to stop. It just compares two time stamps, yours might be from 1971 or something. You needa to Sleep() too. Global $TIMER = TimerInit() Global $TIMERDIFF = 0 Main() Func Main() While 1 $TIMERDIFF = Round(TimerDiff($TIMER) / 1000, 1) ToolTip($TIMERDIFF, 100, 100, "Info", 1, 1) Sleep(10) WEnd WEnd EndFunc 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...
Indiaum Posted March 22, 2015 Author Share Posted March 22, 2015 TimerInit / TimerDiff are not something that runs, to stop. It just compares two time stamps, yours might be from 1971 or something. You needa to Sleep() too. Global $TIMER = TimerInit() Global $TIMERDIFF = 0 Main() Func Main() While 1 $TIMERDIFF = Round(TimerDiff($TIMER) / 1000, 1) ToolTip($TIMERDIFF, 100, 100, "Info", 1, 1) Sleep(10) WEnd WEnd EndFunc I see, thank you. Link to comment Share on other sites More sharing options...
iamtheky Posted March 23, 2015 Share Posted March 23, 2015 (edited) It was intentional, i thought that i could keep a timer stopped, and only use the TimerInit() to start it in a specific moment. After the TimerInit(), is it possible to stop it? If I have interpreted this correctly you just want to keep a running time that can be started and stopped. And timerinit can get by for this task (you are just starting it over and adding it to the last value), search 'stopwatch' on the forums, but here is a crude example that will keep a running total of how long the gui has spent with the Start button pressed: expandcollapse popup#include <GUIConstantsEx.au3> Global $TIMER = 0 Global $LastTime = 0 GUICreate("Test" , 400 , 400) $ButtonStart = GUICtrlCreateButton("START" , 10 , 100) $ButtonStop = GUICtrlCreateButton("STOP" , 100 , 100) GUICtrlSetState($ButtonStop , $GUI_DISABLE) $edit = GuiCtrlCreateEdit ("" , 200 , 1 , 200 , 400) GUISetState(@SW_SHOW) while 1 Switch GUIGetMsg() Case $ButtonStart GUICtrlSetState($ButtonStop , $GUI_ENABLE) GUICtrlSetState($ButtonStart , $GUI_DISABLE) Main() Case $ButtonStop GUICtrlSetState($ButtonStop , $GUI_DISABLE) GUICtrlSetState($ButtonStart , $GUI_ENABLE) Stop() Case -3 exit EndSwitch wend Func Main() $TIMER = TimerInit() EndFunc Func Stop() $RunningTime = Round(TimerDiff($TIMER) / 1000, 1) $TotalTime = $LastTime + $RunningTime GUICtrlSetData($edit , GuiCtrlRead($edit) & $TotalTime & @CRLF) $LastTime = $TotalTime EndFunc Edited March 23, 2015 by boththose ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) 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