ddk Posted July 10, 2012 Share Posted July 10, 2012 Hi There, I'm new with autoit scripting and try to make my job automate. This simple script running on my local pc ( XP) but when I try to schedule it on server 2008 R2 64bit, the updater won't start because the windows not on top ( not become active windows ) On the tray, show scipt paused and the updater windows just blinking on taskbar. ; Run the Updater.exe Run("D:\updater.exe") WinWaitActive("Data Update - Data Location") Send("!n") WinWaitActive("LocalDataUpdater") Send("!y") Exit anyone please help me to make it run the "updater.exe" and execute "next" & "yes" thank you Link to comment Share on other sites More sharing options...
rvn Posted July 10, 2012 Share Posted July 10, 2012 (edited) Welcome to Autoit forum make sure window exist, try this script ; Run the Updater.exe Run("D:updater.exe") ;wait 2 second Sleep(2000) show_window("Data Update - Data Location") Send("!n") show_window("LocalDataUpdater") Send("!y") Exit ;check window first, exist or not Func show_window($wTitle) If WinExists($wTitle) Then WinActivate($wTitle) WinWaitActive($wTitle) Else MsgBox(0,"Window not exist. Exiting!") Exit EndIf EndFunc Edited July 10, 2012 by rvn Link to comment Share on other sites More sharing options...
OrthodoxyUSA Posted July 10, 2012 Share Posted July 10, 2012 (edited) Hi There, I'm new with autoit scripting and try to make my job automate. This simple script running on my local pc ( XP) but when I try to schedule it on server 2008 R2 64bit, the updater won't start because the windows not on top ( not become active windows ) On the tray, show scipt paused and the updater windows just blinking on taskbar. ; Run the Updater.exe Run("D:updater.exe") WinWaitActive("Data Update - Data Location") Send("!n") WinWaitActive("LocalDataUpdater") Send("!y") Exit anyone please help me to make it run the "updater.exe" and execute "next" & "yes" thank you Adding one more line after WinWaitActive should do the trick. ; Run the Updater.exe Run("D:updater.exe") WinWaitActive("Data Update - Data Location") WinActivate("Data Update - Data Location") Send("!n") WinWaitActive("LocalDataUpdater") Send("!y") Exit Paul Edited July 10, 2012 by OrthodoxyUSA Link to comment Share on other sites More sharing options...
Bert Posted July 10, 2012 Share Posted July 10, 2012 It is better whenever possible to use controlsend. The reason is (As you have experienced first hand) if the window loses focus the script breaks. Controlsend will interact with the control you want no matter if the window has focus or not. The Vollatran project  My blog: http://www.vollysinterestingshit.com/ Link to comment Share on other sites More sharing options...
ddk Posted July 10, 2012 Author Share Posted July 10, 2012 Welcome to Autoit forum make sure window exist, try this script ; Run the Updater.exe Run("D:updater.exe") ;wait 2 second Sleep(2000) show_window("Data Update - Data Location") Send("!n") show_window("LocalDataUpdater") Send("!y") Exit ;check window first, exist or not Func show_window($wTitle) If WinExists($wTitle) Then WinActivate($wTitle) WinWaitActive($wTitle) Else MsgBox(0,"Window not exist. Exiting!") Exit EndIf EndFunc hi rvn.. , many thanks for your suggest, this trick work for me, I get error. i don't know who's faster Error message "windows not exist" shows since I only need to focus windows for starter, I just use "show_windows" function for first time only. So a little modification code below and work great for me ; Run the Updater.exe Run("D:updater.exe") ;wait 2 second Sleep(2000) show_window("Data Update - Data Location") Sleep(2000) Send("!n") WinWaitActive("LocalDataUpdater") Send("!y") Exit ;check window first, exist or not Func show_window($wTitle) If WinExists($wTitle) Then WinActivate($wTitle) WinWaitActive($wTitle) Else MsgBox(0,"Window not exist. Exiting!") Exit EndIf EndFunc Adding one more line after WinWaitActive should do the trick. ; Run the Updater.exe Run("D:updater.exe") WinWaitActive("Data Update - Data Location") WinActivate("Data Update - Data Location") Send("!n") WinWaitActive("LocalDataUpdater") Send("!y") Exit Paul hi Paul, thank for you smart trick, it work on my win7 but for my OS (win server 2008 R2 64bit) still cannot focus to the program. It is better whenever possible to use controlsend. The reason is (As you have experienced first hand) if the window loses focus the script breaks. Controlsend will interact with the control you want no matter if the window has focus or not. scullion.., this is interesting and will do for my next automation. thanks all for helping me and I will mark it as "SOLVED" Link to comment Share on other sites More sharing options...
rvn Posted July 11, 2012 Share Posted July 11, 2012 nice to hear it Link to comment Share on other sites More sharing options...
ddk Posted July 12, 2012 Author Share Posted July 12, 2012 nice to hear it thanks again all.. 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