AutoIt 脚本可以在未登录时作为计划任务运行吗?
我正在使用 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")
I am using Ruby/WATIR/AutoIt to automate a task via Task Scheduler which runs fine as long as I am logged in, but soon as my account is locked or I logout, the script stops functioning.
When I log back in it is where AutoIt is supposed to handle a file download dialogue (by clicking save, then entering the filename and clicking save again).
Following code works while I am logged in. Is AutoIt supposed to work when I am not logged in, and is there some other way to accomplish this?
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")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅当有人登录且桌面解锁时,发送击键的 AutoIt 脚本才会起作用。
为了进一步说明,任何发送击键的程序只有在有人登录并且桌面解锁的情况下才能工作。
AutoIt scripts that send keystrokes will only work if someone is logged in and the desktop is unlocked.
For further clarification, any program that sends keystrokes will only work if someone is logged in and the desktop is unlocked.
未登录时,Windows 会激活另一个窗口,因此您无法执行任何与窗口相关的操作。但控制命令可能仍然有效。
相关。
When not logged in Windows makes a different window active and hence you cannot do any window related operation. But control command may still work.
Related.