1
votes

I'm trying to send some text to an inputput box using win32. Some text appears in the inputbox, but it is all jumbled (?????????a??????).

The code is :

SendMessage(myHandle, WM_SETTEXT, 1, "A")

2
Is the input box in the same process? Is it a standard Win32 input box? Is it expecting unicode?Brannon
Yes, Yes (I belive the input part is technically an edit) and I'm not sure. Examples I have seen, just use plain text.jedd
Are you building your application as UNICODE or ANSI? Usually you will see question marks like that if the control is expecting a unicode string, but you are sending ANSI.Brannon
The inputbox is not created from my application, it is created externally (say from a vbscript file). I don't know what encoding it should take, it appears to be a standard edit control. My application is written in VB.NET. I tried changing the encoding to : SendMessage(myHandle, WM_SETTEXT, 0, Encoding.UTF8.GetBytes("A").toString) Same results. Is that what you were suggesting?jedd

2 Answers

3
votes

I don't know if this is the root cause, but as long as the target window (edit box in your case) is in the same process, you should call SetWindowText() rather than sending WM_TEXT directly.

HTH,

0
votes

It should be something like this as mentioned below:-

SendMessage(myHandle,WM_SETTEXT,NULL,(LPARAM)L"A");