I use Ruby / WATIR / AutoIt to automate a task using the task scheduler, which works fine while I logged in, but soon when my account is locked or I log out, the script stops functioning.
When I get back, here AutoIt should handle the file download dialog (by clicking the "Save" button, then enter the file name and click "Save" again).
The following code works while I am logged in. Is AutoIt supposed to work when I am not logged in, and is there any other way to do 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")
source
share