Sign in to follow this  
Followers 0
ddk

program not start because windows not active on 2008 R2 64bit

7 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by rvn

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by OrthodoxyUSA

Share this post


Link to post
Share on other sites

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" :D

Share this post


Link to post
Share on other sites

nice to hear it :)

Share this post


Link to post
Share on other sites

nice to hear it :)

thanks again all.. :D

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