I saw this post: http://www.ranorex.com/forum/post3169.html?hilit=get form handle#p3169
And I tried the code as follows (note BrowserWin is a Form element):
Dim hwnd as long
hwnd = cint(BrowserWin.Element.GetAttributeValue("Handle").tostring)
And it gives me a number, but not the same value I saw in Spy.
How can I get the handle number I saw in Spy? I saw that it returns intprt, but I just assummed I could convert that to a long and get the same thing....
Thanks,
Aracknid
How to get a Form handle?
- Support Team
- Site Admin
- Posts: 12145
- Joined: Fri Jul 07, 2006 4:30 pm
- Location: Houston, Texas, USA
- Contact:
Re: How to get a Form handle?
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 wayAracknid wrote:I saw this post: post3169.html?hilit=get form handle#p3169

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.html
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:And it gives me a number, but not the same value I saw in Spy.
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.Aracknid wrote:I saw that it returns intprt, but I just assummed I could convert that to a long and get the same thing....
long handleLong = handle.ToInt64();Regards,
Alex
Ranorex Team