我正在使用 Ruby/WATIR/AutoIt 通过任务计划程序自动执行任务,只要我登录该任务计划程序就可以正常运行,但是一旦我的帐户被锁定或我注销,脚本就会停止运行。
当我重新登录时,AutoIt 应该处理文件下载对话框(通过单击保存,然后输入文件名并再次单击保存)。
以下代码在我登录时有效。 AutoIt 在我未登录时是否应该工作,还有其他方法可以实现吗?
prompt_message = "Do you want to save this file, or find a program online to open it?"
window_title = "File Download"
save_dialog = WIN32OLE.new("AutoItX3.Control")
sleep 1
save_dialog_obtained = save_dialog.WinWaitActive(window_title,prompt_message, 25)
save_dialog.ControlFocus(window_title, prompt_message, "&Save")
sleep 1
save_dialog.Send("S")
save_dialog.ControlClick(window_title, prompt_message, "&Save")
save_dialog.WinSetTitle(window_title, prompt_message, "This is ForTesting" )
saveas_dialog_obtained = save_dialog.WinWait("Save As", "Save&in", 5)
sleep 1
path = fileName
puts " Edit the file path"
save_dialog.ControlSend("Save As", "", "Edit1",path)
sleep 4
puts " Save the file"
save_dialog.ControlClick("Save As", "Save &in", "&Save")
save_fileAlreadyExists = save_dialog.Send("Y")