Jump to content

TimerInit + TimerDiff problem


 Share

Recommended Posts

Alright, in this basic example the so to say Session Timer works if $GUISessionTime value stays low...

If you make the $GUISessionTime = 180 or something significant, it stops working...meaning the session never ends.

I'm totally stomped here...

Is there a better way to do this?

#include <file.au3>  
    HotKeySet("{ESC}", "Terminate")
    $GUISessionTime = 10  ;minutes     ;IniRead(@ScriptDir & "\myProg.ini", "Options", "SessionTime", "")
    ;MsgBox(0, "Reading .ini GUI session time", $GUISessionTime)
    $SessionTime = (($GUISessionTime * 60000) + Random(- 30000, 60000, 1))
    _FileWriteLog(@DesktopDir & "\myProg.log", " SessionTime = " & $SessionTime )
    $SessionTimer = TimerInit()
        
    While 1
        Sleep(100)
        If TimerDiff($SessionTimer) > $SessionTime Then
            ExitLoop
        EndIf
    WEnd
    _FileWriteLog(@DesktopDir & "\myProg.log", " SessionTimer exceeded desired session time.")
    EndSession() 
    
    Func EndSession()
        Sleep(500)
        Send("{SPACE}")
        Terminate()
    EndFunc   ;==>EndSession
    Func Terminate()
        _FileWriteLog(@DesktopDir & "\myProg.log", "////////////// Exited Script/////////////////////////////////////////")
        Exit 0
    EndFunc   ;==>Terminate
Edited by Oldschool
Link to comment
Share on other sites

Did you actually set it to 180 minutes and wait 180 minutes for it to end? Maybe you should create a gui with a label showing time elapsed and time remaining.

Well, this structure is part of another script, and yes I let the script run, come back after the supposed session end, and it's still running.

I can use _NowCalc() I guess instead of this...

I'm almost positive that TimerDiff() is limited somehow...

Link to comment
Share on other sites

Try this simplification to see if you have a real problem (which I doubt):

$iTimer = TimerInit()
$sStart = @HOUR & ":" & @MIN & ":" & @SEC
Do
    Sleep(100)
Until TimerDiff($iTimer) > (180 * 60 * 1000) ; 3Hrs
MsgBox(64, "Time Test", "Start: " & $sStart & @CRLF & "  End: " & @HOUR & ":" & @MIN & ":" & @SEC)

:P

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
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...