Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7751797
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:38:21+00:00 2026-06-01T11:38:21+00:00

I want to set up text in edit box programatically in other program, which

  • 0

I want to set up text in edit box programatically in other program, which is a game app and using directX, but running in window mode. I’m doing this:

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 not working for me…. but some how once worked. I think I misunderstood something, maybe it must focus on edit control, then set cursor then paste text and then disable focus… I realy don’t know much…please save my time and nervs, tell me how to make it working….

I tried this too, and not working:

SendMessage(hwnd, WM_SETTEXT, NULL, (LPARAM)"text");

hwnd is correct, but text is not updated… it send to correct handle, but not updated…. I think I need somehow to focus or update, once it updated successful, but I didnt realized what happened…so code worked once, but no more working… why one time it worked?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:38:23+00:00Added an answer on June 1, 2026 at 11:38 am

    Your question is money! Seriously. Let’s say a little bird told me what’s the game you are interested at (starts with an S). I’ve spent a few hours myself on this problem and I’ve had some success, so I’ll share it with you.

    There’s a tool named Spy++ (from Microsoft) that let’s you watch messages that are sent to a window/class. This is great for debugging because it allows you to monitor the messages that are sent to the EDIT box when a key is pressed on your keyboard, so you can find out the exact calls and parameters that are send to the game to simulate this operation.

    Use spy++ to open the game process, and once you are in Game’s login window you will see that spy++ reports several threads opened in this process, but only one thread is going to have 3 EDIT boxes. That is the thread you are interested at!

    Also notice that neither of the EDIT boxes have caption, so the following code will never work:

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

    and by the way, always make sure that FindWindowEx() returns something valid, else how would you know that it succeeded finding the edit box?

    What you should do instead is:

    HWND edit = FindWindowEx(hWnd, NULL, "", NULL);
    if (!edit)
    {
        // report error
    }
    

    And this will find the first EDIT box. This box corresponds to the username box. The game uses 3 PostMessage() calls to simulate a key press, and not SendMessage() as you were trying:

    // "..." means you need to find out the other parameters
    PostMessage(edit, WM_KEYDOWN, ...); 
    PostMessage(edit, WM_CHAR, ...); 
    PostMessage(edit, WM_KEYUP, ...); 
    

    Spy++ will reveal what the other parameters are, don’t worry. You will probably spend some time figuring out how the last parameter of the call is built (because it’s a mask).

    I haven’t been able to send keys to the game if it was minimized or without focus. You will have to figure this one out. For testing purposes, use can use SetForegroundWindow(window_hwnd); and some more stuff to focus the window.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to set the text on a JButton that is size 32x32 but
i have a problem, i want set text of a UILabel or UItextView or
I want to set the Text of a TextBlock in my StatusBar before making
I want to set the text direction for some cells in a TextTable so
I want to set a text in a specific label on focus of an
I want to set some text at a specified offset in my JTextArea .
SHORT DESCRIPTION OF PROBLEM: I want to set the text of a searchbar without
I have a ListActivity and I want to set programmatically the text of a
I want to set the Expires header for all image/* and text/css . I'm
I'm using a combo box control and the dataprovider is set as an XML.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.