SendKeys problem when using Non-English Windows keyboard layouts

D

davermcl

Hi,

I'm experiencing a problem when using the VB SendKeys method. I'm
sending characters to a textbox in another application. It works fine
when the Windows Input Languages on both apps are set to English, but
if they are set to say German, I'm getting the wrong characters in my
client textbox.

This is my SendKeys statement:
SendKeys.Send(MyString)


Thanks in advance,

davidm
 
C

Claes Bergefall

The docs for SendKeys.Send says that you should avoid it in applications
intended for international use since it can lead to unpredictable results.
Guess you just proved that :-(.

That being said, I have successfully used it with a bunch of different
keyboard layouts. However I only sent international characters, so I guess
it depends on what characters you're actually trying to send. Do you have to
send the actual keystrokes? If all you want to do is set the text in the
textbox there are other ways (see WM_SETTEXT)

/claes
 
C

Claes Bergefall

That should say "...I only sent standard English characters (i.e. 7-bit
ASCII)..."

/claes
 
D

davermcl

Thanks for your response!

yes I do want to send the actual keystrokes in order to simulate a
physical keyboard.

Usually only 2-3 ASCII characters display incorrectly when using
non-English layouts. I just thought there may be a workaround for this
problem.

But I might have to resort to the 'keybd_event' API call which I would
like to avoid because SendKeys works great in all other aspects of our
application such as sending text to a textbox within the same
application.

davidm
 
G

Guest

Hi,

I'm experiencing a problem when using the VB SendKeys method. I'm
sending characters to a textbox in another application. It works fine
when the Windows Input Languages on both apps are set to English, but
if they are set to say German, I'm getting the wrong characters in my
client textbox.

You need to change the keyboard layout of the sending application to match
the keyboard layout of the focused application.

We offer a .NET component FREE for non-commercial use that will work great
with non-English keyboards (except for complex keyboards which require IME):

http://www.mini-tools.com/goto/input
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top