Reputation: 67
I'm trying to get some sort of script working so It checks two files every 5 mins to check if they've updated/changed/been modified.
If file 1 has been updated/changed/been modified it should do one thing, if file 2 has been updated/changed/been modified it should close a certain program and launch a new program then change the programs title and move it to 0, 0 (top left of screen)
The part I don't know how to do is the checking the files to see if they've been updated/changed/been modified.
Could someone help me and point me in the right direction?
Thanks in advance :)
Upvotes: 1
Views: 2176
Reputation: 31
You are looking for FileGetTime
, specifically with the option set to 0 (modified)
Func Timecheck()
$file1_2 = FileGetTime("C:\file1.txt", 0, 1)
$file2_2 = FileGetTime("C:\file2.txt", 0, 1)
If $file1_1 == $file1_2 Then
; Do something here if file 1 isn't modified within 5ins
EndIf
If $file2_1 == $file2_2 Then
; Maybe WinClose?
WinClose("programhere")
; Maybe ProcessClose
ProcessClose("process.exe")
; Launch your program...
Run(...)
; Wait for process
ProcessWait("process.exe")
; Wait for Program...
WinWait("programhere")
WinSetTitle("programhere", "", "newprogramhere")
WinMove("newprogramheret", "", 0, 0, 800, 600, 1)
EndIf
$file1_1 = FileGetTime("C:\file1.txt", 0, 1)
$file2_1 = FileGetTime("C:\file2.txt", 0, 1)
EndFunc
; Initial Launch, grab current GetTime
$file1_1 = FileGetTime("C:\file1.txt", 0, 1)
$file2_1 = FileGetTime("C:\file2.txt", 0, 1)
While 1
Sleep(300000)
Timecheck()
WEnd
Reference: http://www.autoitscript.com/autoit3/docs/functions/FileGetTime.htm
Upvotes: 2