简体   繁体   中英

Using SendMessage to change the text in the foreground window obtained by GetForegroundWindow changes only the title, not the text inside the window

When I am using SendMessage for any process which is found by FindWindowEX then it's working fine and I am able to send text to particular application.

When I am using the GetForegroundWindow to find a window and trying to send text then it's not working. It's setting the title text rather then sending text into window.

could you please help me to resolve it, have a look on below code

//using FindWindowEX  
Process[] notepads = Process.GetProcessesByName("notepad");  
FindWindowEx(notepads[0].MainWindowHandle, new IntPtr(0), "Edit", null);
SendMessage(child, 0x000C, 0, "testing");

//Using GetForegroundwidow  
IntPtr child = GetForegroundWindow();(0), "Edit", null);  
SendMessage(child, 0x000C, 0, "testing");

Sending the WM_SETTEXT message to a top-level window changes the title. If you want to change the text inside the window, you need to perform application-specific operations. (Different applications manage their contents differently.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM