AutoIt 脚本可以在未登录时作为计划任务运行吗?

发布于 2024-09-01 00:14:29 字数 1063 浏览 6 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心头的小情儿 2024-09-08 00:14:29

仅当有人登录且桌面解锁时,发送击键的 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.

追风人 2024-09-08 00:14:29

未登录时,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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文