Jump to content

Recommended Posts

  • Moderators
Posted

How can I compare the time stamp of a file with the current system time. What I'm trying to accomplish with this is to have the script wait for a program to updates a certain file, and when it does I want it to carry out the next function. So if the time stamp is within 10 minutes of the current system time then it will continue, if not then it will wait until it is.

  • Moderators
Posted

You can do FileReadLine() or put the time stamp in a specific location in an .ini and do an IniRead().

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

This should work well for you:

#Include <Date.au3>

; Get the last-modified time of the file
Local $FGT = FileGetTime('C:\AutoExec.bat')
; Convert that to a format expected by _DateDiff()
Local $FileDateAsString = $FGT[0] & '/' & $FGT[1] & '/' & $FGT[2] & ' ' & $FGT[3] & ':' & $FGT[4] & ':' & $FGT[5]
; Determine the number of seconds since the last-modified time
Local $Age = _DateDiff('s', $FileDateAsString, _NowCalc())

; Wait until the file is ten minutes old if necessary
If $Age < (10 * 60) Then
    Local $TimeToSleep = ((10 * 60) - $Age) * 1000
    Sleep($TimeToSleep)
EndIf

; Do the rest
; ...

P.S. I like your avatar!

  • Moderators
Posted

That's exactly what I was looking for!!!

This is what I have so far:

#Include <Date.au3>
    $x = @DesktopWidth/2
    $y = @DesktopHeight/2
         ToolTip("Please Wait...", $x, $y, "Audit in progress")
    Do
    ; Get the last-modified time of the file
        Local $FGT = FileGetTime('C:\TrackitAudit.id')
    ; Convert that to a format expected by _DateDiff()
        Local $FileDateAsString = $FGT[0] & '/' & $FGT[1] & '/' & $FGT[2] & ' ' & $FGT[3] & ':' & $FGT[4] & ':' & $FGT[5]
    ; Determine the number of seconds since the last-modified time
        Local $Age = _DateDiff('s', $FileDateAsString, _NowCalc())
    ;Wait until the file is less than 1 minute old      
        Sleep(2000)
        Until $Age < (60)

How can I keep the tooltip visible from before the Do statement until after it gives a true value?

P.S. Thanks I made it in Ulead Cool 3D Studio here a while back.

  • Moderators
Posted

Okay, let me explain this a little better.

$x = @DesktopWidth/2

$y = @DesktopHeight/2

ToolTip("Please Wait...", $x, $y, "Audit in progress")

;This is where I want the tooltip to start of course

Do

; Get the last-modified time of the file

Local $FGT = FileGetTime('C:\TrackitAudit.id')

; Convert that to a format expected by _DateDiff()

Local $FileDateAsString = $FGT[0] & '/' & $FGT[1] & '/' & $FGT[2] & ' ' & $FGT[3] & ':' & $FGT[4] & ':' & $FGT[5]

; Determine the number of seconds since the last-modified time

Local $Age = _DateDiff('s', $FileDateAsString, _NowCalc())

;Wait until the file is less than 1 minute old

Sleep(2000)

Until $Age < (60)

;This is where I want it to end

WinClose("Track-It! Audit")

Exit

Hopefully this helps clear things up a little.
  • Moderators
Posted

Put the ToolTip 'start' inside the Do loop, that way it refreshes every loop, it will stop automatically after the loop has ended.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Posted

This should work well for you:

#Include <Date.au3>

; Get the last-modified time of the file
Local $FGT = FileGetTime('C:\AutoExec.bat')
; Convert that to a format expected by _DateDiff()
Local $FileDateAsString = $FGT[0] & '/' & $FGT[1] & '/' & $FGT[2] & ' ' & $FGT[3] & ':' & $FGT[4] & ':' & $FGT[5]
; Determine the number of seconds since the last-modified time
Local $Age = _DateDiff('s', $FileDateAsString, _NowCalc())

; Wait until the file is ten minutes old if necessary
If $Age < (10 * 60) Then
    Local $TimeToSleep = ((10 * 60) - $Age) * 1000
    Sleep($TimeToSleep)
EndIf

; Do the rest
; ...

P.S. I like your avatar!

nice looking code alex (as usual) but possibly a little overkill?

While 1
$blah = Number(FileGetTime(@ScriptFullPath,2,1))
$blah2 = Number(@YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC)
If $blah2 - $blah < 1000 Then
    MsgBox(0,"Ding","Your file is less than 10 minutes old"
    Exit
EndIf
WEnd
  • Developers
Posted (edited)

nice looking code alex (as usual) but possibly a little overkill?

While 1
$blah = Number(FileGetTime(@ScriptFullPath,2,1))
$blah2 = Number(@YEAR & @MON & @MDAY & @HOUR & @MIN & @SEC)
If $blah2 - $blah < 1000 Then
    MsgBox(0,"Ding","Your file is less than 10 minutes old"
    Exit
EndIf
WEnd
This isn't gonna work...

assume filedatetime: 20051220125500

assume currdatetime: 20051220130000

diff = 4500 but only 5 minutes....

The _DateDiff() function works better ... :P

Edited by JdeB

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Posted

This isn't gonna work...

assume filedatetime: 20051220125500

assume currdatetime: 20051220130000

diff = 4500 but only 5 minutes....

The _DateDiff() function works better ... :P

ah... yet another good argument for trying more than current data. back to the corner for me...
  • Moderators
Posted

Put the ToolTip 'start' inside the Do loop, that way it refreshes every loop, it will stop automatically after the loop has ended.

Well that works, but it sits there and flickers each time it loops. I guess it's not that big of a deal though.

Posted

Have you considered using SplashTextOn()? --

#Include <Date.au3>

SplashTextOn('Audit in progress', @LF & 'Please wait...', 144, 64)
Do
; Get the last-modified time of the file
    Local $FGT = FileGetTime('C:\TrackitAudit.id')
; Convert that to a format expected by _DateDiff()
    Local $FileDateAsString = $FGT[0] & '/' & $FGT[1] & '/' & $FGT[2] & ' ' & $FGT[3] & ':' & $FGT[4] & ':' & $FGT[5]
; Determine the number of seconds since the last-modified time
    Local $Age = _DateDiff('s', $FileDateAsString, _NowCalc())
; Wait until the file is less than 1 minute old     
    If $Age > 60 Then Sleep(2000)
Until $Age < 60
SplashOff()

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
  • Recently Browsing   0 members

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