SendKeys

D

Daniel

Hi,

I want to use the SendKeys function in a multilingual enviroment - The
client computers have 2 languages or more.
The problem is I want to send an english sequence but if the keyboard is in
different language the key sequence is sent using this language.
I tried to use the API - ActivateKeyboardLayout and change the language to
english - it changes the language but still sends in the current language...
:-(

Any ideas ?
 
K

Karl E. Peterson

Daniel said:
I want to use the SendKeys function in a multilingual enviroment - The
client computers have 2 languages or more.
The problem is I want to send an english sequence but if the keyboard
is in different language the key sequence is sent using this language.
I tried to use the API - ActivateKeyboardLayout and change the
language to english - it changes the language but still sends in the
current language... :-(

Any ideas ?

Use the current language?
 
K

Karl E. Peterson

Daniel said:
I need to send a path for a file name - and it's only english...

Maybe there's another way to accomplish what you're trying to do. Hard to
guess, though, without knowing what it is you're trying to do. (As opposed
to what you're telling us -- how you're trying to do whatever _it_ is.)
 
D

Daniel

OK....
I did it this way:

Private Declare Function ActivateKeyboardLayout Lib "user32" (ByVal HKL As
Long, ByVal flags As Long) As Long
Private Const LANG_EN_US = 67699721

ActivateKeyboardLayout LANG_EN_US, 1
SendKeys "whatever", true
 
K

Karl E. Peterson

Daniel said:
OK....
I did it this way:

Private Declare Function ActivateKeyboardLayout Lib "user32" (ByVal
HKL As Long, ByVal flags As Long) As Long
Private Const LANG_EN_US = 67699721

ActivateKeyboardLayout LANG_EN_US, 1
SendKeys "whatever", true

The reason I wrote this:
Maybe there's another way to accomplish what you're trying to do.
Hard to guess, though, without knowing what it is you're trying to
do. (As opposed to what you're telling us -- how you're trying to do
whatever _it_ is.)

Is because SendKeys is notoriously flakey, and more often than not leads to
difficult-to-impossible to diagnose and correct problems. I was trying to
gently suggest that perhaps another method to accomplish your goal was worth
considering, but that without understanding your goal there was no way for
anyone here to guess what that might be.

Sorry... Karl
 
M

Mini-Tools Timm

Daniel said:
I want to use the SendKeys function in a multilingual enviroment - The
client computers have 2 languages or more.
The problem is I want to send an english sequence but if the keyboard is in
different language the key sequence is sent using this language.
I tried to use the API - ActivateKeyboardLayout and change the language to
english - it changes the language but still sends in the current language...
:-( Any ideas ?

I think some of the confusion may be your term "language". This implies if
you call SendKeys("yes"), it will type "oui" for French users.

Instead, I suspect you are really talking about the keyboard layout. i.e.,
If you SendKeys("yes"), you want it to type "yes" no matter what language
keyboard is being used. Is this correct?

The trick is to use AttachThreadInput to attach your process to the input
thread of the focused application. That way when you call SendKeys, the keys
will be sent according to the keyboard layout of the focused application.

We offer a .NET component FREE for non-commercial use that sends text using
the proper keyboard layout and handles most international keyboards:
http://www.mini-tools.com/goto/input
 
Top