'How to focus textbox and send ENTER key using child handle?

How to focus and send 'ENTER' key to child control's textbox? code:

 //Get textbox child handle
 IntPtr TextboxChild = FindWindow("Edit", "mulatetwindow");
 //SetFocus to textbox
 int WM_COMMAND = 0x111;
 int EN_SETFOCUS = 0x0100;
 SendMessage(TextboxChild, WM_COMMAND, EN_SETFOCUS, null);
 //Send ENTER key
 int WM_KEYDOWN = 0x100;
 int VK_RETURN = 0x0D;
 int WM_KEYUP = 0x101;
 SendMessage(TextboxChild, WM_KEYDOWN, VK_RETURN, null);
 System.Threading.Thread.Sleep(100);
 SendMessage(TextboxChild, WM_KEYUP, VK_RETURN, null);

I tried the code in above, it didn't work.

spy

spy2



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source