Allochthonous Posted October 30, 2009 Share Posted October 30, 2009 I have a script that launches a backup program by opening an associated "job" file. When this window becomes active, the script clicks the "Run" button, the job runs, showing its status in a new window. When this window shows the "Job finished" message, the script closes the job execution window and the main program window. The script is tied to a task in Windows Task Scheduler on a machine that I remote desktop into. It is scheduled to run at 1:00 AM when nobody is using the box. The account is left logged onto the machine pretty much all of the time. It runs just fine when I execute it "live". However, when it runs via Task Scheduler, the main program window opens, but then apparently loses focus and sits until someone remotes in and then clicks on the window. Below is a sample of the code. I have changed the name of the application, as I am trying to cheat a full backup out of a trial version that only lets you schedule a partial backup. This is the latest variation that I have tried. It is sloppy I know...desperation. Can anyone help me? Opt("WinTitleMatchMode", 2) ShellExecute("BackUp.job", "","[PATH]") WinActivate("Backup Application Title") WinWaitActive("Backup Application Title") ControlClick("Backup Application Title", "", "Run") WinWaitActive("Job Execution Status", "Job finished") WinClose("Job Execution Status") WinWaitClose("Job Execution Status") WinActivate("Backup Application Title") WinWaitActive("Backup Application Title") WinClose("Backup Application Title") PK Link to comment Share on other sites More sharing options...
Bert Posted October 30, 2009 Share Posted October 30, 2009 Have you tried to see if your app has command line support? The Vollatran project My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
Allochthonous Posted October 30, 2009 Author Share Posted October 30, 2009 Excellent question. It does indeed have command line support, but this lauches the limited version and only does a partial backup. I have to initiate the backup via the GUI to get a full backup. PK Link to comment Share on other sites More sharing options...
Baraoic Posted October 30, 2009 Share Posted October 30, 2009 It looks like you only do winwaitactive you could try looping WinExists("Backup Application Title") every second then when it finds it then do a winactive to see if that helps. Link to comment Share on other sites More sharing options...
Allochthonous Posted October 30, 2009 Author Share Posted October 30, 2009 That was a prrtty good idea. I modfied the code to look like this. Same behavior. The window opens, but loses focus and the script sits idle until I log in and click it. Opt("WinTitleMatchMode", 2) ShellExecute("BackUp.job", "","[PATH]") Do Until WinExists("Backup Application Title") WinActivate("Backup Application Title") WinWaitActive("Backup Application Title") ControlClick("Backup Application Title", "", "Run") WinWaitActive("Job Execution Status", "Job finished") WinClose("Job Execution Status") WinWaitClose("Job Execution Status") WinActivate("Backup Application Title") WinWaitActive("Backup Application Title") WinClose("Backup Application Title") Link to comment Share on other sites More sharing options...
Allochthonous Posted November 2, 2009 Author Share Posted November 2, 2009 Well, after some testing at home this weekend, apparently the culprit is Windows Task Scheduler. If i use a third party scheduler (System Scheduler), it seems that the window does not lose focus if it runs while the PC is locked. Anyone have any ideas? I really did not want to use a third party scheduler. Can anyone reoommend one? When i tried to install System Scheduler at work, our Symantec AV did not like it and would not let me. pk Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now