Jump to content
Sign in to follow this  
JohnRichard

How to record the time?

Recommended Posts

JohnRichard

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.

Share this post


Link to post
Share on other sites
JohnRichard

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?

Share this post


Link to post
Share on other sites
Juvigy

_NowTime - Display a time using the 24-hour format (hh:mm:ss)

Share this post


Link to post
Share on other sites
Mat

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

Share this post


Link to post
Share on other sites
JohnRichard

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

Share this post


Link to post
Share on other sites
Spiff59

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

Share this post


Link to post
Share on other sites
Mat

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

Share this post


Link to post
Share on other sites
weaponx

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.

Share this post


Link to post
Share on other sites
JohnRichard

works great. this is what i am trying to figure out. thanks spiff. i have fun learning AutoIt from you guys.

cheers... :)

Share this post


Link to post
Share on other sites
JohnRichard

another great idea...thanks mdiesel...

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.