Jump to content

How to record the time?


Recommended Posts

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

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

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 by mdiesel
Link to comment
Share on other sites

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

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 by Spiff59
Link to comment
Share on other sites

#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.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...