1

Possible Duplicate:
Using SendMessage to enter text into an edit control belonging to another process

I want to set up text in edit control of directx window programatically. I can get correct handle of edit control, but text is inserted only if I click on Edit control, How can insert text without clicking on Edit control. I'm doing this:

HWND hWnd = FindWindow(NULL,"Game");
HWND edit = FindWindowEx(hWnd, NULL, "Edit", NULL);

SendMessage(edit, WM_CHAR, (TCHAR) 'H', 0);
Sleep(100);
SendMessage(edit, WM_CHAR, (TCHAR) 'E', 0);
Sleep(100);
SendMessage(edit, WM_CHAR, (TCHAR) 'L', 0);
Sleep(100);
SendMessage(edit, WM_CHAR, (TCHAR) 'L', 0);
Sleep(100);
SendMessage(edit, WM_CHAR, (TCHAR) 'O', 0);
Sleep(100);

Parent window hides/disables the edit control when I move away from edit control.

this code is working only if I click Edit control at same time when code running.... but how to make it programatically and full automated to insert text without clicking on Edit control. It is possible to do this all in background?

Community
  • 1
  • 1
Jigberto
  • 1,513
  • 7
  • 27
  • 50
  • Not again! OK I Google it for you... WM_CHAR on MSDN: 'Posted to the window with the keyboard focus when a WM_KEYDOWN message is translated by the TranslateMessage function.' 'WITH THE KEYBOARD FOCUS!' – Martin James Apr 03 '12 at 10:58
  • It's still bogus to use `WM_CHAR` rather than `WM_SETTEXT`. The question is actually all about the behaviour of the target app which hides or disables the edit control when you move away from it. But you didn't mention that. No doubt it will come out (again) in comments below. Please please do not keep asking the same question. You didn't get an answer last time because the question was very poor. Asking the same question just makes us angry. – David Heffernan Apr 03 '12 at 11:45
  • @David Heffernan If you know what I want then why you not post your answer, and just tell me dont make us angry..... if you dont know or not want to help, then go away. P.S.: yes, it hides/disables the edit control when I move away from edit control. – Jigberto Apr 03 '12 at 12:20
  • The question can't be answered because you haven't provided any details. Sending `WM_SETTEXT` works on my machine with my target app. What's different about yours. If you won't tell us we can't help. And don't ask the same question again and again. – David Heffernan Apr 03 '12 at 12:22
  • 1
    OK, what was the LRESULT that was returned in the SendMessage call? The one I suggested you check in the last post exchange. If a control does not want to process the message because it's disabled or hidden, what are you asking us for? – Martin James Apr 03 '12 at 12:25
  • I'm not asking you..... if you dont know what I want or not able to understand my problem, then dont be stupid you and above users.... – Jigberto Apr 03 '12 at 12:48
  • Well, I was trying to help. I think you can judge by the answers to your two identical questions that the problem is with the question. But since you don't want me to try to help, I will bow out at this point. – David Heffernan Apr 03 '12 at 13:26

1 Answers1

0

How about Edit_SetText?

Ringding
  • 2,856
  • 17
  • 10