我的代码工作不一致,但成功率很高。
它的作用是保存ahk文件并自动在我的Dropbox文件夹中备份它。但是,不一致的部分是有时候备份不会在保管箱文件夹中完成。我应该如何更改脚本以确保备份在100%的时间内完成?谢谢!
我的代码如下:
RCtrl::
SaveMyFile()
CloseAhk() ; to backup ahk file in dropbox & close editor
Return
SaveMyFile() { ; to save the ahk file and reload it
WinGetActiveTitle, Reload
If InStr(Reload, ".ahk") { ; to check if it is ahk file
MsgBox, , , to_run.ahk is reloaded, 0.6
Send ^s
Reload
}
Else
Send ^s
}
CloseAhk() {
IfWinActive, to_run.ahk - Notepad
{
FileAhkBackup() ; calls the backup function
WinClose ; to close the ahk file
}
}
FileAhkBackup() { ; the backup function
FileCopy, C:\Users\xxx\Desktop\to_run.ahk, C:\Users\xxx\Dropbox\AHK\, 1
}
再次感谢:)
答案 0 :(得分:0)
尝试在那里投入几千个睡眠,并确保在上一个过程完成之前没有尝试发送过程。