Tstudent Posted October 23, 2011 Share Posted October 23, 2011 Please, can you show me the most efficent way to do this? i want to launch a file, but only if the time of another file is > then 09:00 pm In another words: if the time (last saved) of "fileA.xls" is > then 09:00pm then open "fileB.bat" otherwise wait 1 minute and restart the control until the time condition is verified. Is possible to do this with autoit? Thank you Link to comment Share on other sites More sharing options...
DesireDenied Posted October 23, 2011 Share Posted October 23, 2011 (edited) dont know if this is what you are looking for, have not tested but should do the trick. $sFileToCheck = "FileA.xls" $sFileToRun = "FileB.bat" While 1 $aFileTime = FileGetTime($sFileToCheck) If IsArray($aFileTime) Then If $aFileTime[3] >= 9 Then Run($sFileToRun) ExitLoop Else Sleep(1000) EndIf EndIf WEnd Edited October 23, 2011 by DesireDenied Link to comment Share on other sites More sharing options...
Tstudent Posted October 23, 2011 Author Share Posted October 23, 2011 dont know if this is what you are looking for, have not tested but should do the trick. $sFileToCheck = "FileA.xls" $sFileToRun = "FileB.bat" While 1 $aFileTime = FileGetTime($sFileToCheck) If IsArray($aFileTime) Then If $aFileTime[3] >= 9 Then Run($sFileToRun) ExitLoop Else Sleep(1000) EndIf EndIf WEnd Thank you, works very well. I have modified this code because i want add another check: i want that day, month and year of "FileA.xls" are equal to CURRENT day, month and year. #include <Date.au3> $sFileToCheck = "c:\AAA.xlsx" $sFileToRun = "c:\BBB.bat" $tCur = _Date_Time_GetLocalTime() $aCur = _Date_Time_FileTimeToArray($tCur) While 1 $aFileTime = FileGetTime($sFileToCheck) If IsArray($aFileTime) Then If $aFileTime[0] = $aCur[0] and $aFileTime[1] = $aCur[1] and $aFileTime[2] = $aCur[2] And $aFileTime[3] = 21 and $aFileTime[4] >= 41 Then Run($sFileToRun,"c:\") ExitLoop Else Sleep(10000) EndIf EndIf WEnd But day, month, year check doesn't work. Any ideas? Thank you 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