YoseMite Posted June 27, 2006 Posted June 27, 2006 Hi! I'm working on a script that shows how many hours/minutes/secs I'm working on the computer. This works perfect, but now I want save every 5 min to a text file to get the total hours. The problem is that the first 5min work, but then I can't get it work. The timer must save it to 10min but he doesn't do that. Here is the script: expandcollapse popup#include <GUIConstants.au3> #include <Date.au3> Global $Secs, $Mins, $Hour, $Time ;Create GUI GUICreate("Timer",200, 200) GUICtrlCreateLabel("00:00:00", 10,10) GUISetState() ;Start timer $timer = TimerInit() AdlibEnable("Timer", 50) $StartTicks = _TimeToTicks("00:00:00") While 1 $msg = GUIGetMsg() ;If time is 1 sec -> next time 5 min if ($Time = "00:00:01") Then ;Set time to 5 min $EndTicks = $StartTicks + 5 * 60 * 1000 _TicksToTime($EndTicks,$Hour,$Mins,$Secs) $next = "0" & $Hour & ":0" & $Mins & ":0" & $Secs ;If time is 5min -> show message msgbox(0,"Next time",$next) ;Filewrite now 5 minutes to a txt file ;If time is 10min -> save time EndIf ;FileWriteLine("debug.log",@min & ":" & @sec & " ==> after") Select Case $msg = $GUI_EVENT_CLOSE ;Show the total time of the program msgbox(64,"Total time of this session:",$Time) Exit EndSelect Wend ;Function timer 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 I removed the part that must to +5min because that always sucks. Can anyone please help me? Thanks! YoseMite
Uten Posted June 27, 2006 Posted June 27, 2006 Hi, Take a look at TimerInit, TimerDiff and Adlibenable. Make shure you understand how the samples work and do some search on the forum. Do the search in the header only is often more productive than the default option. This code should write to a log every 5min(not tested:)): Adlibenable("writelog", 5*60*1000) ;use milliseconds While GetGuMsg() <> -3 sleep(250) WEnd Exit Func WriteLog() ConsoleWrite("WriteLog called: " & @Min & ":" & @SEC & @LF) EndFunc The sample you have used as a starting point is not the best for your application. Also, do you want to log how long your script has been runnning or how long you have been working (as in done some activity. keyboard input mouse movements)? Please keep your sig. small! Use the help file. Search the forum. Then ask unresolved questions :) Script plugin demo, Simple Trace udf, TrayMenuEx udf, IOChatter demo, freebasic multithreaded dll sample, PostMessage, Aspell, Code profiling
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