Adapters & Elements

Ask general questions here.
atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Adapters & Elements

Post by atom » Wed Jul 15, 2009 4:06 pm

Hiya Ranorex,

I identify a control in ranorex spy. I see lots of nice properties...
I then check the API ... where are these properties?!

Why isnt your API developed so each adapter class exposes its properties as PROPERTIES, and enumerated strings as an enumerated types instead!

Anyway for my question....

I have a Form object, the form could be Win32, WinForms or WPF ... all I want is the native window handle
How can I do that ?

Thanks
Clayton

slither
Posts: 11
Joined: Thu Jun 18, 2009 3:27 pm

Re: Adapters & Elements

Post by slither » Wed Jul 15, 2009 5:24 pm

All the juicy details are located in the Element of the adapter (myAdapter.Element).

To get the window handle:

Ranorex.Form frm = @"RxPath to a form";
IntPtr hWnd = (IntPtr) frm.Element.GetAttributeValue("Handle");

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Re: Adapters & Elements

Post by atom » Wed Jul 15, 2009 6:13 pm

will that work for WPF windows?

slither
Posts: 11
Joined: Thu Jun 18, 2009 3:27 pm

Re: Adapters & Elements

Post by slither » Wed Jul 15, 2009 8:10 pm

It should. I just did a test with a sample WPF application, and it returned a proper Window Handle.

atom
Posts: 357
Joined: Sun Dec 07, 2008 11:14 pm
Location: Dublin, Ireland

Re: Adapters & Elements

Post by atom » Thu Jul 16, 2009 9:24 am

cheers!

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Adapters & Elements

Post by Support Team » Wed Jul 13, 2011 10:28 pm

Just a follow-up on this post as it has been linked to recently by another post:
atom wrote:Why isnt your API developed so each adapter class exposes its properties as PROPERTIES, and enumerated strings as an enumerated types instead!
Actually, the API is and was always designed that way :D Check out the corresponding topic in the Ranorex User Guide:
http://www.ranorex.com/support/user-gui ... apter.html
atom wrote:I have a Form object, the form could be Win32, WinForms or WPF ... all I want is the native window handle
Not all forms have a window handle depending on their technology, only those supporting the "NativeWindow" capability/adapter. To get the window handle from a Win32 form, you can use following code:
Ranorex.Form form = ...; // your code to get the form
Ranorex.NativeWindow window = new Ranorex.NativeWindow(form);
IntPtr handle = window.Handle;
Regards,
Alex
Ranorex Team