Alan D. Ayers Posted March 2, 2007 Posted March 2, 2007 I have a VB program running that can get 3 reports dumped into Excel. I did not want to copy the code and create it in AutoIT so I used the Windows Functions to automate it. Problem is when I setup a task in the scheduled tasks to run the script every 30-40 minutes on a machine that has no monitor attached it does not seem to work. Any advice would be greatly appreciated. Code Below #region --- ScriptWriter generated code Start --- Dim $EXE ; ; Setup the session ; Opt("WinWaitDelay",100) Opt("WinTitleMatchMode",1) Opt("WinDetectHiddenText",0) Opt("MouseCoordMode",1) ; ; Run the program and login ; $EXE = @ScriptDir & "\EOLDB.EXE" Run($EXE) ControlSend winwait("Login","",1) if WinExists("WST-Routing","") Then WinActivate("WST-Routing","This application is already loaded") MouseClick("Left",509,419) Else WinWait("Login","") If Not WinActive("Login","") Then WinActivate("Login","") WinWaitActive("Login","") Send("SCCMP915") ; Server pit-cs-m607 (test) sccmp915 (prod) MouseClick("Left",639,403) ; DataBase Drop Down MouseClick("Left",569,425) ; Select wst-routing (only one) MouseClick("Left",500,437) ; Login Button EndIf WinWait("End of Line Database","") If Not WinActive("End of Line Database","") Then WinActivate("End of Line Database","") WinWaitActive("End of Line Database","") ; ; Get the Reports screen up ; MouseClick("Left",974,566) MouseClick("Left",932,612) MouseClick("Left",761,661) WinWait("Export Case Master Schedule Summary Report to Excel","") If Not WinActive("Export Case Master Schedule Summary Report to Excel","") Then WinActivate("Export Case Master Schedule Summary Report to Excel","") WinWaitActive("Export Case Master Schedule Summary Report to Excel","") ; ; Run the first report for Shipping ; MouseClick("Left",610,360) ;Bring Up Drop down MouseClick("Left",523,381) ;Select Shipping Report Type RunAndWaitForDone() ; ; Run the second report for Assembly ; MouseClick("Left",610,360) ;Bring Up Drop down MouseClick("Left",523,392) ;Select Assembly Report Type RunAndWaitForDone() ; ; Run the last report for CRM ; MouseClick("Left",610,360) ;Bring Up Drop down MouseClick("Left",523,406) ;Select CRM Report Type RunAndWaitForDone() ; ; Clean up and move out ; MouseClick("Left",525,434) WinWait("End of Line Database","") If Not WinActive("End of Line Database","") Then WinActivate("End of Line Database","") WinWaitActive("End of Line Database","") MouseClick("Left",984,661) WinWait("WST - Routing","") If Not WinActive("WST - Routing","") Then WinActivate("WST - Routing","") WinWaitActive("WST - Routing","") MouseClick("Left",470, 431) #endregion --- ScriptWriter generated code End --- ; ; Common Run and wait until done ; Func RunAndWaitForDone() MouseClick("Left",478,456) ;Run The report WinWait("WST - Routing","") ;Wait for done If Not WinActive("WST - Routing","") Then WinActivate("WST - Routing","") WinWaitActive("WST - Routing","") MouseClick("Left",513,419) ;Click ok on the done Button WinWait("Export Case Master Schedule Summary Report to Excel","") ;Wait for main report screen If Not WinActive("Export Case Master Schedule Summary Report to Excel","") Then WinActivate("Export Case Master Schedule Summary Report to Excel","") WinWaitActive("Export Case Master Schedule Summary Report to Excel","") EndFunc
lod3n Posted March 2, 2007 Posted March 2, 2007 If you are running it from a scheduled task under a different account than the one logged in, or if the screen is locked, no window can become "Active". Use WinWait, and WinExists, etc. [font="Fixedsys"][list][*]All of my AutoIt Example Scripts[*]http://saneasylum.com[/list][/font]
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