Take the 2-minute tour ×

hey, i have a window from a program, when i view it in UIspy i noticed that the RuntimeIds of the childs is like:

"window"      RuntimeId:        "42 1510446"  //parent
    "pane"    RuntimeId:        "42 394736"
    "image"   RuntimeId:        "42 1510446 2 0"
    "button"  RuntimeId:        "42 1510446 2 1"
    "text"    RuntimeId:        "42 1510446 2 2"

i need to get the content of "text" and i have a function that can do that but i need the hwnd. does "text" have a hwnd (it should be 1510446 or something) ? or how can i access it?

share|improve this question
UISpy uses the UIAutomation API to get its information. If you're not planning on using UIAutomation, you might want to use Spy++ instead, since it shows just HWNDs; can then use FindWindow() to get at the HWND. What type of window/application is this that you're looking at? –  BrendanMcK Apr 26 '11 at 0:24
thanks, i used UIAutomation. FindWindow never works with me. the type of window is win32 ( i think?) –  Alex Apr 26 '11 at 22:58
add comment

1 Answer

The HWND is assigned when the text window is created and so will differ everytime the window containing it is loaded.

You would need to:

  1. Get the HWND of the containing window with FindWindow(Ex)
  2. Using that as the parent HWND call FindWindowEx again specifying TEXT as the class name
  3. Get the size of the actual text content with SendMessage / WM_GETTEXTLENGTH & create a buffer
  4. Fill that buffer with the value using SendMessage / WM_GETTEXT

This assumes there is only one of that window class on the parent window and that text is an implementation of the stock EDIT class.

share|improve this answer
i have tried that, FindWindowEx returns only "pane"'s HWND (394736) and does not return any other result. –  Alex Apr 25 '11 at 21:27
add comment

Your Answer


