Getting a reference of an object present in another .net application.<div>Hi, </div> <div>For automation purpose i had to get the reference of an object/Control(for e.x a textbox) which is open in another .net application. I was able to retrieve the handle of that .net applcation form. but i was not able to obtain the reference of that form. </div> <div>I tried to using control.FromHandle(handle) function. but it returns a null for the handle i passed since the handle is not associated to the application I am running.</div> <div>I also tried to add the handle to my application with the following code.</div> <div><br/></div> <div>        Dim nw As New NativeWindow</div> <div>        nw.AssignHandle(&amp;H100300A)</div> <div><span style="white-space:pre"> </span>'&amp;H100300A is a valid windows handle for an application which is open <br/></div> <div>        Dim c As Control = Control.FromHandle(nw.Handle)</div> <div><br/></div> <div>but c returned nothing.</div> <div>Is there any way using which i can get the reference of an object in another .net appliction from my application.</div> <div>Thanks in advance.</div>© 2009 Microsoft Corporation. All rights reserved.Mon, 06 Jul 2009 11:14:00 Zddd47c6a-9f35-4667-93cc-4f049c16978ehttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ddd47c6a-9f35-4667-93cc-4f049c16978e#ddd47c6a-9f35-4667-93cc-4f049c16978ehttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ddd47c6a-9f35-4667-93cc-4f049c16978e#ddd47c6a-9f35-4667-93cc-4f049c16978ekumar Bhttp://social.msdn.microsoft.com/Profile/en-US/?user=kumar%20BGetting a reference of an object present in another .net application.<div>Hi, </div> <div>For automation purpose i had to get the reference of an object/Control(for e.x a textbox) which is open in another .net application. I was able to retrieve the handle of that .net applcation form. but i was not able to obtain the reference of that form. </div> <div>I tried to using control.FromHandle(handle) function. but it returns a null for the handle i passed since the handle is not associated to the application I am running.</div> <div>I also tried to add the handle to my application with the following code.</div> <div><br/></div> <div>        Dim nw As New NativeWindow</div> <div>        nw.AssignHandle(&amp;H100300A)</div> <div><span style="white-space:pre"> </span>'&amp;H100300A is a valid windows handle for an application which is open <br/></div> <div>        Dim c As Control = Control.FromHandle(nw.Handle)</div> <div><br/></div> <div>but c returned nothing.</div> <div>Is there any way using which i can get the reference of an object in another .net appliction from my application.</div> <div>Thanks in advance.</div>Sun, 28 Jun 2009 12:34:33 Z2009-06-28T16:31:28Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ddd47c6a-9f35-4667-93cc-4f049c16978e#ca337531-9a83-40b5-a39c-a683c990b1d7http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ddd47c6a-9f35-4667-93cc-4f049c16978e#ca337531-9a83-40b5-a39c-a683c990b1d7p.b.ahttp://social.msdn.microsoft.com/Profile/en-US/?user=p.b.aGetting a reference of an object present in another .net application.You can use this project - http://white.codeplex.com/ to automate your rich client applications. <br/>Tue, 30 Jun 2009 14:19:34 Z2009-06-30T14:19:34Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ddd47c6a-9f35-4667-93cc-4f049c16978e#ae4b7ddc-a328-4054-bb1d-a223351acbd8http://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ddd47c6a-9f35-4667-93cc-4f049c16978e#ae4b7ddc-a328-4054-bb1d-a223351acbd8kumar Bhttp://social.msdn.microsoft.com/Profile/en-US/?user=kumar%20BGetting a reference of an object present in another .net application.HI p.b.a, <div><span style="white-space:pre"> </span>Thanks for your reply.But this could not resolve the issue becuasethe environment which I am using is .net 2.0, but the prerequisite of WHITE project is .net 3.0. So was not able to work.  <div><br/></div> <div><br/></div> </div>Thu, 02 Jul 2009 11:50:16 Z2009-07-02T11:50:16Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ddd47c6a-9f35-4667-93cc-4f049c16978e#29fcfbe3-c0ff-4b7b-819a-a9ff309cad1bhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ddd47c6a-9f35-4667-93cc-4f049c16978e#29fcfbe3-c0ff-4b7b-819a-a9ff309cad1bp.b.ahttp://social.msdn.microsoft.com/Profile/en-US/?user=p.b.aGetting a reference of an object present in another .net application.<div>Kumar, </div> <div><br/></div> To get the window managed object itself you will have to be running in the same process as the application that has the UI, Control.FromHandle will give you back the window (managed) object only if the window is in the process where you're making the call from. If you're out of proc to automate the controls you have to use the Win32 API functions like WindowFromPoint, ChildWindowFromPoint, SendMessage /PostMessage and that's what White does. The project is open source (apache license) and even if you cannot use it as a whole you can still link to parts of it (and give them the credit due).  <div><br/></div> <div>If you have control over the target application an alternative would be to make it load your automation assembly - you will be inproc hence able to use the winforms api.</div> <div><br/></div> <div>HTH</div> <div>Paul</div>Thu, 02 Jul 2009 14:38:08 Z2009-07-02T14:38:08Zhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ddd47c6a-9f35-4667-93cc-4f049c16978e#6e7903f6-1ce7-40bb-a805-c872b5b1ed1dhttp://social.msdn.microsoft.com/Forums/en-US/netfxtoolsdev/thread/ddd47c6a-9f35-4667-93cc-4f049c16978e#6e7903f6-1ce7-40bb-a805-c872b5b1ed1dkumar Bhttp://social.msdn.microsoft.com/Profile/en-US/?user=kumar%20BGetting a reference of an object present in another .net application.Thanks for the replyMon, 06 Jul 2009 11:14:00 Z2009-07-06T11:14:00Z