开发者

Can AutoIt scripts run as a scheduled task while not logged in?

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")


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜