We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now

x

VbScript AppActivate fails to bring focus to window

crashnet
crashnet asked
on
Medium Priority
16,043 Views
Last Modified: 2012-06-27
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
Comment
Watch Question

Leo EikelmanDirector, IT and Business Development

Commented:
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


Leo EikelmanDirector, IT and Business Development

Commented:
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

Author

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
Leo EikelmanDirector, IT and Business Development

Commented:
yeah it should be only one set of double quotes

Leo

Author

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

Author

Commented:
i would like to get a refund on this Q. i found my answer thru another forum.

thanks

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

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.