Insert text into the textbox of another application

Use FindWindowEx() to find the handle (HWND) and then send the WM_SETTEXT message using SendMessage()

When using FindWindowEx you will need to first find the main window handle by using its class name. Then you will need to find the handle of whatever container the textbox is in, calling FindWindowEx, passing the handle of the parent (the window), and the class name of the container. You will need to repeat this until you reach the textbox. You can use a tool called Spy++ that is installed by default with Visual Studio to inspect the target application and find out the hierarchy of containers (all objects are really called windows in the API but I’m calling them containers in contrast with the top-level window) with their class names.

Leave a Comment