Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

virtual keyboard

Status
Not open for further replies.

VBdevil

Programmer
Sep 19, 2002
75
IL
Hi,

I have a virtual keyboard that works in English and in other languages.

My problem is that when I try to write in a different language other than english, and the computer language is on English - it sends the letters to the screen in english.
And vice versa - if I'm writing in english and the computer language is on a different language, it sends the letters to the screen in that other language.

Does anyone know to control this? how can I make it write only in english? Or only in a different language?

I use the SendKeys function to send the letters to the screen. maybe there is a different function I can use?

Thanks!
 
I'm assuming that you mean that it uses the keyboard layout that's consistent with the language the computer's set to, and not that you have inadvertantly invented a program that translates on the fly as you type! Which is what it sounds like you're saying.

You need to give more context to get a good answer. Is this inside a VB program that you're trying to do this? How are you writing? Into a text box? A word document?

Bob
 
Ok - let me explain again:

I have an application that simulates a keyboard.
It's a form with command buttons on it, that writes to any type of text editor (word document, notepad application, text box etc).

This keyboard application can be installed in different languages, and the captions of the command buttons are set according to the language of the installation.

My problem is that if the language that the computer is set to is English then the keyboard strikes are sent in english, no matter if my keyboard program was installed and the captions of the buttons are in a different languge...

Have any ideas?
 
The click event is this:

Private Sub cmd_Click(Index As Integer)
{
Select Case Index
Case 0 To 11
SendKeys(cmd(Index).Caption)
Case 12
SendKeys(Chr$(8)) 'backspace
Case 13 To 33
SendKeys(cmd(Index).Caption)
Case 34
SendKeys (Chr$(13))
Case 35 To 45
SendKeys (cmd(Index).Caption)
Case 46
SendKeys (" ") 'space
End Select
}

what I want to do is control the language that the computer is set to.
Meaning that if I load the keyboard in english then the computer language will be set to English, and If I load it in a different language, then the the computer language will be set to that other language.

(I have a parameter that tells me which language the keyboard is using, so that's no problem)

In order to control the computer language I used the API functions: LoadKeyboardLayout and ActivateKeyboardLayout, but they don't work good.
When I run the keyboard.exe the language of the computer is changed for a second, and is then changed back..

do u know any other API functions I could use?
Or maybe in my click event I could use something else other than the sendKeys function?

 
LoadKeyboardLayout works fine for me. Perhaps we should see your code for loading and activating the keyboard layout

 
the code to change to english looks like this:

HKL = LoadKeyboardLayout("00000409", KLF_ACTIVATE)
call ActivateKeyboardLayout(HKL, KLF_REORDER)

and the other languages are done the same way, only with a different string for the first parameter of the
LoadKeyboardLayout function.

By the way, I tried to use the LoadKeyboardLayout function by itself, and to only use the ActivateKeyboardLayout by itself, but both tries didn't work..

Have any ideas?
Could you maybe write me your code?
 
Hmm - my LoadKeyboardLayout is much the same as yours - and I don't need the AcivateKeyboardLayout to get it working.

Um, if you put a textbox on your form, use LoadKeyboardLayout to load a French layout and then type the letters "QWERTY" into the textbox what do you get (I would expect "AZERTY")?
 
strongm, I don't have french installed, so I can't run that test.

could you write me your LoadKeyboardLayout code?
I'd like to see if maybe you used another flag or something like that.




 
Sure but you'll have to wait about 9 hours as I am nowhere near my VB machine today

I should point out that I don't have French installed either ...
 
Here's my basic code. As I said, it is much the same as yours.
Code:
[blue]
Option Explicit

Const KLF_ACTIVATE  As Long = &H1 'activate the layout

'the language constants
Const LANG_NL_STD As String = "00000413"
Const LANG_EN_US As String = "00000409"
Const LANG_DU_STD As String = "00000407"
Const LANG_FR_STD As String = "0000040C"
Const LANG_SYSTEM_DEFAULT As String = "00000800"
Const LANG_EN_UK As String = "00000809"
Const LANG_USER_DEFAULT As String = "00000400"

'api to adjust the keyboardlayout
Private Declare Function LoadKeyboardLayout Lib "user32" Alias "LoadKeyboardLayoutA" (ByVal pwszKLID As String, ByVal flags As Long) As Long
 
Public Function SetKbLayout(strLocaleId As String) As Boolean
    'Changes the KeyboardLayout
    'Returns TRUE when the KeyboardLayout was adjusted properly, FALSE otherwise
    SetKbLayout = (LoadKeyboardLayout(strLocaleId, KLF_ACTIVATE)) <> 0
End Function[/blue]
 
yeah, your code is very similar..
thanks though..

If you know or think of any other API functions then that would be great..

Anyway, thanks for all your help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top