Jump to content
  • Advertisement
Sign in to follow this  
tziek

[C#] sendmessage WM_CHAR 13 goes BEEP

This topic is 4829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having a problem with the sendmessage (WM_CHAR, 13) to a certain textfield. This is the code I used:
Quote:
[DllImport("user32.dll",EntryPoint="SendMessage", CharSet=CharSet.Auto)] private static extern int SendMessage( int hwnd, int uMsg, int wParam, StringBuilder lParam); private const int WM_CHAR = 0x0102; private const int WM_SETTEXT = 0x000c; ... SendMessage(this.TXT_COMMAND_WINDOW_HANDLER, WM_SETTEXT, command.Length, new StringBuilder(command)); SendMessage(this.TXT_COMMAND_WINDOW_HANDLER, WM_CHAR, 13, new StringBuilder());
I successfully used this code before on Q3 engine games (Q3, rtcw, cod, ...)to send commands to its console. However, when I use this code on Doom3, it succeeds to do the WM_SETTEXT, but the WM_CHAR message fails. The WM_CHAR 13 results in a BEEP and never does the actual enter. My guess is that the WM_CHAR 13 message is somehow blocked? Even though it turns up when I monitor the textfield using spy++. And when I manually press enter in the textbox it works :). Any ideas on how I can force an enter in the textfield?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Toolmaker
Try sending a WM_CHAR 10 first, then the WM_CHAR 13.


WM_CHAR 10 beeps too :)

Quote:

retValue = SendMessage(this.TXT_COMMAND_WINDOW_HANDLER, WM_CHAR, 10, null);
Console.WriteLine("retValue: " + retValue);
retValue = SendMessage(this.TXT_COMMAND_WINDOW_HANDLER, WM_CHAR, 13, null);
Console.WriteLine("retValue: " + retValue);


gives me the result
Quote:

retValue: 1
retValue: 1


On the window where WM_CHAR 13 does work it gives me: (the WM_CHAR 10 is beeping here too)
Quote:

retValue: 1
retValue: 0


So the WM_CHAR 10 message is never processed.

Is it possible that the receiving application blocks these messages, but accepts normal keyboard input? Or is a real enter-keypress generating the same WM_CHAR 13 message? Still can't figure it out :).

Share this post


Link to post
Share on other sites
When you WM_CHAR the quake3 games, does the console window have to be open in them, or does the game always use WM_CHAR for the console whether it's visible or not?

An alternative, depending on circumstances: 'keybd_event'

Other alternatives: WM_KEYDOWN / WM_KEYUP

Share this post


Link to post
Share on other sites
The console window to where i'm sending is actually a hidden window. So my guess is I can't use keybd_event or SendInput (didn't look at it yet).

I'm looking at the WM_KEYDOWN / WM_KEYUP atm.

Share this post


Link to post
Share on other sites
WM_KEYDOWN 13 seems to be ignored as well (works for any other normal key).
I guess i'm officially out of options? :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!