Moderators big_daddy Posted December 20, 2005 Moderators Share Posted December 20, 2005 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. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 20, 2005 Moderators Share Posted December 20, 2005 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. Link to comment Share on other sites More sharing options...
LxP Posted December 20, 2005 Share Posted December 20, 2005 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! Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted December 20, 2005 Author Moderators Share Posted December 20, 2005 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. Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted December 20, 2005 Author Moderators Share Posted December 20, 2005 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. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted December 20, 2005 Moderators Share Posted December 20, 2005 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. Link to comment Share on other sites More sharing options...
seandisanti Posted December 20, 2005 Share Posted December 20, 2005 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 Link to comment Share on other sites More sharing options...
Developers Jos Posted December 20, 2005 Developers Share Posted December 20, 2005 (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 WEndThis isn't gonna work... assume filedatetime: 20051220125500 assume currdatetime: 20051220130000 diff = 4500 but only 5 minutes.... The _DateDiff() function works better ... Edited December 20, 2005 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. Link to comment Share on other sites More sharing options...
seandisanti Posted December 20, 2005 Share Posted December 20, 2005 This isn't gonna work...assume filedatetime: 20051220125500assume currdatetime: 20051220130000diff = 4500 but only 5 minutes....The _DateDiff() function works better ... ah... yet another good argument for trying more than current data. back to the corner for me... Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted December 20, 2005 Author Moderators Share Posted December 20, 2005 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. Link to comment Share on other sites More sharing options...
LxP Posted December 21, 2005 Share Posted December 21, 2005 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() Link to comment Share on other sites More sharing options...
Moderators big_daddy Posted December 21, 2005 Author Moderators Share Posted December 21, 2005 Thank you all for all the help! I think the script is ready for deployment. 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