1

我正在尝试使某种脚本正常工作,因此它每 5 分钟检查两个文件以检查它们是否已更新/更改/被修改。

如果文件 1 已更新/更改/已修改,它应该做一件事,如果文件 2 已更新/更改/已修改,它应该关闭某个程序并启动一个新程序,然后更改程序标题并将其移动到 0, 0(屏幕左上角)

我不知道该怎么做的部分是检查文件以查看它们是否已更新/更改/已修改。

有人可以帮助我并指出正确的方向吗?

提前致谢 :)

4

1 回答 1

2

您正在寻找FileGetTime,特别是选项设置为 0 (修改)

代码示例

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

参考:http ://www.autoitscript.com/autoit3/docs/functions/FileGetTime.htm

于 2013-11-14T15:45:39.983 回答