• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 14890
  • Last Modified:

VbScript AppActivate fails to bring focus to window

hi

the following script does the job (sends ESC to the app and causes it to exit) IF i dont focus on a different window between the moment i run the script and the app is finished starting. if i do select another window between running the script and the app done loading, i can see the title bar for the foremost window (login) on that app blinking every 1 second, but it doesnt not close the app and it loops there until i manually focus back on the app.

when the app starts it opens up a login box named "login". the app is named "store operations manager". it doesnt matter if i bring the focus to the main window or the child window, because it defaults to the login window and as soon as i manually bring focus to it the ESC gets sent and the app exits. the same problem occurs when the script is run as a scheduled task (when there is nobody manually switching focus as i am the only one who logins to this win2003 SBS machine)

Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Run """C:\Program Files\Microsoft Retail Management System\Store Operations\SOMANAGER.exe"""
Do Until Success = True
    Success = objShell.AppActivate("Store Operations Manager")
    Wscript.Sleep 1000
Loop
objShell.SendKeys ("{ESC}")

what is the problem here?
thanks
Set objShell = nothing
0
crashnet
Asked:
crashnet
  • 3
  • 3
1 Solution
 
Leo EikelmanCommented:
maybe the name is too long.  What if u do

<<<<<<<<< SNIP >>>>>>>>>>>
..................
  Success = objShell.AppActivate("Store Op")
  Wscript.Sleep 1000
Loop
objShell.SendKeys "{ESC}"


Cheers,

Leo


0
 
Leo EikelmanCommented:
I dont know if this is of use but it was posted on msdn

http://support.microsoft.com/default.aspx?scid=kb%3Ben-us%3B109262
0
 
crashnetAuthor Commented:
i tried to use "store" and "login". i only need one double quote character on each side, right? cause for the path i needed THREE on each side

i dont think the msdn article applies in my case. i am using the latest version of wscript and vbscript on windows 2003
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
Leo EikelmanCommented:
yeah it should be only one set of double quotes

Leo
0
 
crashnetAuthor Commented:
i found a workaround: i am killing the process instead of sending {ESC} to it and it accomplishes my goal.

thanks to all,
crashnet
0
 
crashnetAuthor Commented:
i would like to get a refund on this Q. i found my answer thru another forum.

thanks

crashnet
0
 
GranModCommented:
Closed, 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now