Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Switching between open applications

Status
Not open for further replies.

NicT

MIS
Oct 15, 2003
2
GB
I am trying to write some code to copy data from Excel and then switch into a CITRIX application and paste it. I am using the sendkeys function to do the copy paste bit but am having difficulty changing the focus between applications. I have tried the sendkeys version on Alt-Tab but it doesn't seem to work. (Both applications are open on the desktop). Can anybody help?
 
Hi,
from the Script56.chm (downloadable via
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "calc"
WScript.Sleep 100
WshShell.AppActivate "Calculator"
WScript.Sleep 100
WshShell.SendKeys "1{+}"

WshShell.AppActivate <titlename> will put the application with that titlename as the active one.

From Script56.chm:
&quot;AppActivate Method
See Also
Running Your Scripts | WshShell Object | SendKeys Method
Activates an application window.

object.AppActivate title
Arguments
object
WshShell object.
title
Specifies which application to activate. This can be a string containing the title of the application (as it appears in the title bar) or the application's Process ID.
Remarks
The AppActivate method returns a Boolean value that identifies whether the procedure call is successful. This method changes the focus to the named application or window, but it does not affect whether it is maximized or minimized.&quot;

Hope this will help you get any further...

Grtz Hanzel

If smile = vbFalse Then
MsgBox(&quot;Smile... Tomorrow will be worse!&quot;, ,&quot;Smile...&quot;)
End If
 
Thanks Hanzel, This worked perfectly. Unfortunately sendkeys will not work in my Citrix application so its back to the drawing board. Think I might look at Keyboard_Event in VB.

Thanks again
Nic
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top