JohnRichard Posted May 13, 2009 Share Posted May 13, 2009 hi to all. i am trying to record the time to connect to computer remotely via VNC but i don't know how will i record it or will create a timer until i close my connection to VNC. i can record the time start i connect using the time macro @hour:@min:@sec. my problem is how can i get the time when i disconnect to client. forgive me if this sounds stupid to ask for you guys... appreciate any suggestion or ideas from you. thank you. Link to comment Share on other sites More sharing options...
oMBRa Posted May 13, 2009 Share Posted May 13, 2009 TimerInit, TimerDiff Link to comment Share on other sites More sharing options...
JohnRichard Posted May 13, 2009 Author Share Posted May 13, 2009 TimerInit, TimerDiff thanks oMBRa.but this returns time in milliseconds. i want to record the time when i close my connection in format @hour:@min:@sec. i have tried this code using the TimerInit and TimerDiff Do $begin = TimerInit() Run("calc.exe") Sleep(5000) Until ProcessClose("calc.exe") $dif = TimerDiff($begin) MsgBox(0, "", $dif) any good ideas to record my connection time? Link to comment Share on other sites More sharing options...
Juvigy Posted May 13, 2009 Share Posted May 13, 2009 _NowTime - Display a time using the 24-hour format (hh:mm:ss) Link to comment Share on other sites More sharing options...
Mat Posted May 13, 2009 Share Posted May 13, 2009 (edited) You can let Autoit do all the sums for you if you prefer: ;-) #Include <Date.au3> Global $iHours = 0, $iMins = 0, $iSecs = 0 $iBegin = TimerInit() Sleep(5000) $iEnd = TimerDiff($iBegin) _TicksToTime($iEnd, $iHours, $iMins, $iSecs) ConsoleWrite(StringFormat("%02d:%02d:%02d", $iHours, $iMins, $iSecs) & @CRLF) M23 Basicly, look up ticks to time. Edited May 13, 2009 by mdiesel AutoIt Project Listing Link to comment Share on other sites More sharing options...
JohnRichard Posted May 13, 2009 Author Share Posted May 13, 2009 Basicly, look up ticks to time. thanks mdiesel. i'm confused now. sorry coz i'm newbie here...what i have tried is this code. i have simulated a calculator to replace a VNC window just to see how the timerdiff and timerinit will work..here is what i have...... $calc = WinExists("Calculator","") $begin = TimerInit() If $calc Then Do $begin = TimerInit() Until WinWaitClose("Calculator","") $dif = TimerDiff($begin) MsgBox(0, "", $dif) Else Do $begin = TimerInit() WinWait("Calculator","") Until WinWaitClose("Calculator","") $dif = TimerDiff($begin) MsgBox(0, "", $dif) EndiF i wonder how will i add the _tickstotime on this... Link to comment Share on other sites More sharing options...
Spiff59 Posted May 13, 2009 Share Posted May 13, 2009 (edited) Something like this? #include<date.au3> Dim $h, $m, $s WinWait("Calculator","") $start = _NowCalc() $timer = TimerInit() WinWaitClose("Calculator","") $timer = TimerDiff($timer) $end = _NowCalc() _TicksToTime($timer, $h, $m, $s) $dur = StringFormat("%02i:%02i:%02i", $h, $m, $s) MsgBox(1,"", "Started at: " & $start & @CRLF & "Ended at : " & $end & @CRLF & "Duration : " & $dur) edit: lost the '#' in my include statement Edited May 13, 2009 by Spiff59 Link to comment Share on other sites More sharing options...
Mat Posted May 13, 2009 Share Posted May 13, 2009 #Include <Date.au3> $calc = WinExists("Calculator","") $begin = TimerInit() Global $iHours = 0, $iMins = 0, $iSecs = 0 If $calc Then $begin = TimerInit() Until WinWaitClose("Calculator","") $dif = TimerDiff($begin) _TicksToTime($dif, $iHours, $iMins, $iSecs) MsgBox(0, "", StringFormat("%02d:%02d:%02d", $iHours, $iMins, $iSecs)) Else $begin = TimerInit() WinWait("Calculator","") Until WinWaitClose("Calculator","") $dif = TimerDiff($begin) _TicksToTime($dif, $iHours, $iMins, $iSecs) MsgBox(0, "", StringFormat("%02d:%02d:%02d", $iHours, $iMins, $iSecs)) EndiF Untested code. AutoIt Project Listing Link to comment Share on other sites More sharing options...
weaponx Posted May 13, 2009 Share Posted May 13, 2009 If AutoIt is launching the program with RunWait() you just record @HOUR @MIN @SEC before and after RunWait(). You can find the duration using _DateDiff. Link to comment Share on other sites More sharing options...
JohnRichard Posted May 13, 2009 Author Share Posted May 13, 2009 works great. this is what i am trying to figure out. thanks spiff. i have fun learning AutoIt from you guys. cheers... Link to comment Share on other sites More sharing options...
JohnRichard Posted May 13, 2009 Author Share Posted May 13, 2009 another great idea...thanks mdiesel... 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