Aracknid wrote:I saw this post: post3169.html?hilit=get form handle#p3169
I added
a new post to that forum thread, since the code you copied from there is not what we at Ranorex recommend (you can do it that way, but it is not as easy as the recommended way

). Basically, you should always use the Ranorex adapter classes to get attribute values, since then you don't need to use the attribute names a strings:
Ranorex.Form form = ...; // your code to get the form
Ranorex.NativeWindow window = new Ranorex.NativeWindow(form);
IntPtr handle = window.Handle;
See following section in the Ranorex User Guide for more information on Ranorex adapters:
http://www.ranorex.com/support/user-gui ... apter.htmlAracknid wrote:And it gives me a number, but not the same value I saw in Spy.
If you get the handle from the same element, it will give you the same value. Just make sure that you use the same element and be aware that the window handle changes every time the window is created.
Aracknid wrote:I saw that it returns intprt, but I just assummed I could convert that to a long and get the same thing....
If you need to get the value as a long, you can do so, but both handleLong.ToString() and handle.ToString() will give you the same value.
long handleLong = handle.ToInt64();
Regards,
Alex
Ranorex Team