1

What I'm trying to do is get a handle to a TextBox in another windows form. I'm looking at it through Inspect.exe which is telling me the name is "Login:" and the classname is "Edit" (can't take a screenshot, sorry). I can get a handle to everything like buttons, static's..., except for Edit controls. I'm trying with this:

hwnd = FindWindow(null, "WindowTitle");
IntPtr hButton = FindWindowEx(hwnd, IntPtr.Zero, "Button", "Login");
IntPtr hUser = FindWindowEx(hwnd, IntPtr.Zero, "Edit", "Login:");
IntPtr hPass = FindWindowEx(hwnd, IntPtr.Zero, "Edit", "Pass:");

I tried using the label's as childAfter, but no success. Whatever I do, I can't get a handle to the Edit controls. Anyone have any clue what I might be doing wrong? Also it should be noted that the static controls have the same names as the edit controls.

Smurfy
  • 23
  • 4
  • 2
    Inspect.exe is a useful tool to help you write UI Automation code. It classifies the type of the control, it does *not* tell you the class name. Use Spy++ to see the class name. You'll then see that it is not "Edit", class names in Winforms are auto-generated and unpredictable. So use UI Automation instead of FindWindowEx(), System.Windows.Automation namespace. – Hans Passant Dec 09 '17 at 13:22
  • But why does it work for other controls, except for Edit? In inspect.exe there is a row "className". – Smurfy Dec 09 '17 at 13:25

0 Answers0