Sign in to follow this  
Followers 0
hankh

Run as Scheduled Task

9 posts in this topic

Hi,

I have my AutoIt3 script.exe as Windows Sceduled Task.

Everything seems works ok but at the end...

The script calls a compiled Visual FoxPro EXE then sleeps for 10 minutes.

Sleep(600000). This window seems enough to take care of everything.

A couple things, first the "MAXWIN.exe" never gets back focus

and second, my scheduled Task keeps running indefinately.

Any Help Appreciated, Thanks.

Send("#r")

WinWaitActive("Run")

Send("maxwin.exe{Enter}")

WinWaitActive("Login")

Send("{ENTER}")

;WinWaitActive("Choose an Address Book List")

;Send("{ENTER}")

sleep(20000) ;Pause 20 secs for Max to open and read a book

Run("g:\code\con2000\data\ttomaxup.exe")

;Sleep(840000) ;Pause 14 minutes for FoxPro to execute.

;Sleep(780000) ;Pause 13 minutes for FoxPro to execute.

Sleep(600000) ;Pause 10 minutes for FoxPro to execute.

;WinActivate("Microsoft Visual FoxPro")

;WinWaitActive("Microsoft Visual FoxPro")

;WinClose("Microsoft Visual FoxPro")

WinActivate("Maximizer Enterprise [APEX2001]")

;WinWaitActive("Maximizer Enterprise [APEX2001]")

send("!f")

send("{DOWN 17}")

Send("{ENTER}")

Share this post


Link to post
Share on other sites



Does it work when you run it yourself, but not as a Scheduled Task? When running as a scheduled task, are you logged in? Is the workstation locked? No window can ever be Active when there is no visible windows session running. So WinWaitActive will wait forever.


[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

Instead of :

Send("#r")
WinWaitActive("Run")
Send("maxwin.exe{Enter}")
WinWaitActive("Login")
Send("{ENTER}")
;WinWaitActive("Choose an Address Book List")
;Send("{ENTER}")oÝ÷ Ù:ò­æx.¦íän©ÝFéÖj+_ºw-ì{az¥¥ø¥x  l¢)ìµæ¡ö®¶­sg6VæBgV÷C²b333¶bgV÷C²§6VæBgV÷C·´DõtâwÒgV÷C²¥6VæBgV÷C·´TåDU'ÒgV÷C²

Perhaps WinClose() might be better?


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Does it work when you run it yourself, but not as a Scheduled Task? When running as a scheduled task, are you logged in? Is the workstation locked? No window can ever be Active when there is no visible windows session running. So WinWaitActive will wait forever.

YES- actually does work when launching it myself. As a scheduled task I am logged in and not locked.

I am visually monitoring whats going on. In my code "WinWaitActive" is commented out, so only the

other WinActivate is executable. Note that when my "ttomaxup" (FoxPro exe) is launched, the first process launched (Maxwin.exe) runs minimized.

Share this post


Link to post
Share on other sites

Instead of :

Send("#r")
WinWaitActive("Run")
Send("maxwin.exe{Enter}")
WinWaitActive("Login")
Send("{ENTER}")
;WinWaitActive("Choose an Address Book List")
;Send("{ENTER}")oÝ÷ Ù:ò­æx.¦íän©ÝFéÖj+_ºw-ì{az¥¥ø¥x  l¢)ìµæ¡ö®¶­sg6VæBgV÷C²b333¶bgV÷C²§6VæBgV÷C·´DõtâwÒgV÷C²¥6VæBgV÷C·´TåDU'ÒgV÷C²

Perhaps WinClose() might be better?

If the Maxwin process is running minimized, would I have to first "WinActivate" it before "WinClose"?

Share this post


Link to post
Share on other sites

If the Maxwin process is running minimized, would I have to first "WinActivate" it before "WinClose"?

Why not write a little test script and try it out?

Open notepad

minimise

Winclose("notepad")


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

Why not write a little test script and try it out?

Open notepad

minimise

Winclose("notepad")

THANKS EVERYONE!

Finally got everything to work! Firstly, my FoxPro exe takes about 10 minutes to run. My

script sleeps for 10 minutes after launching FoxPro.

I discovered that I had my Windows Scheduled Task to terminate after 10 minutes running!

(So my script did not have a chance to "WinClose") - OOPS!

At the end of my script I now have "WinActivate" then "WinClose" - works great.

(WinKill gets me closure errors)

:P

Share this post


Link to post
Share on other sites

<...>

(WinKill gets me closure errors)

:P

WinKill() should always be a last resort. It's similar to opening the task manager and forcibly ending the task on an application or a process.

WinClose() asks the program to shut itself down, allowing the process to tidy up and take out the garbage, IE: Closing and/or removing temp files, unloading from memory gracefully, etc....


Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

Instead of waiting 10 minutes, regardless of how long it actually takes (11 minutes, or maybe nine on a good day?), try this:

While ProcessExists("ttomaxup.exe")
sleep(1000)
wend

I think scheduled tasks run in their own environment space too, so WinActivate, WinWaitActive, etc still won't work. Try WinExists instead.

Edited by lod3n

[font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0