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....
Ask general questions here.
2 posts • Page 1 of 1
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:Aracknid 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,