Create application object for already launched application without using attach process

Jun 11, 2008 at 11:11 AM
Edited Jun 11, 2008 at 11:18 AM
Hello,
        I am trying to get the Application object or Window object for an application that is already started. Pasting the code for doing it without normal UIAutomation without white.



PropertyCondition

nameCondition = new PropertyCondition(AutomationElement.NameProperty, "MyApp"); 

 

PropertyCondition typeCondition = new PropertyCondition(AutomationElement.ControlTypeProperty, ControlType.Window); 

 

AndCondition cond = new AndCondition(nameCondition, typeCondition); 

 

AutomationElement window = AutomationElement.RootElement.FindFirst(TreeScope.Element | TreeScope.Descendants, cond);




Please let me know how to get the window object without attaching to the process.  I am needing to update the process id every time i launch the app. Is there a method in which I can do that?

Thnx,
Sasidhar.

 

 

Coordinator
Jun 12, 2008 at 2:13 PM
Have you tried Application.Launch("processName")? Does your processName change everytime?
Jun 12, 2008 at 2:19 PM
Hello Vivek,
               The app i am dealing with is *already launched(. I am trying to automate it *after it has launched*.  I need to get the Application object after it has launched.
My program should run with the instance of an application object thats already there in the memory.

Thnx,
Sasidhar.
Coordinator
Jun 13, 2008 at 7:51 PM
I am sorry, I meant to say, Application.Attach("processName")?
You should be able to use this.