I want to adjust the text in the edit box programmatically in another program, which is a game application and uses directX, but works in window mode. I'm doing it:
HWND hWnd = FindWindow(NULL,"Game"); HWND edit = FindWindowEx(hWnd, NULL, "Edit", NULL); SendMessage(edit, WM_CHAR, (TCHAR) 'H', 0); SendMessage(edit, WM_CHAR, (TCHAR) 'E', 0); SendMessage(edit, WM_CHAR, (TCHAR) 'L', 0); SendMessage(edit, WM_CHAR, (TCHAR) 'L', 0); SendMessage(edit, WM_CHAR, (TCHAR) 'O', 0);
this does not work for me .... but some of them somehow worked. I think I didn’t understand something, maybe he should focus on editing, then position the cursor, then paste the text, and then turn off the focus ... I really don't know much ... please save my time and nerves, tell me how to do it works ....
I tried this too and didn't work:
SendMessage(hwnd, WM_SETTEXT, NULL, (LPARAM)"text");
hwnd is correct, but the text is not updated ... it sends the correct descriptor, but it is not updated .... I think I need to somehow focus or update as soon as it is updated, but I did not understand what happened ... so the code worked once, but no longer worked ... why did it work once?