Input Language

R

Rajkiran R.B.

Well I have multiple keyboard layouts installed in my system..

I have written a program in C# such that the required input language can be
selected using the following piece of code

InputLanguage[] lang = new
InputLanguage[InputLanguage.InstalledInputLanguages.Count];

private void Form1_Load(object sender, EventArgs e)
{
richTextBox1.LanguageOption =
RichTextBoxLanguageOptions.AutoKeyboard;
InputLanguage.InstalledInputLanguages.CopyTo(lang, 0);
foreach (InputLanguage l in lang)
{
comboBox1.Items.Add(l.Culture.EnglishName);
}
comboBox1.SelectedIndex =
comboBox1.Items.IndexOf(InputLanguage.DefaultInputLanguage.Culture.EnglishName);
comboBox1.SelectedItem =
InputLanguage.DefaultInputLanguage.Culture.EnglishName;
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
InputLanguage.CurrentInputLanguage =
lang[comboBox1.SelectedIndex];
richTextBox1.Focus();
}

So with the above code I could change the language and the change can be
seen when I type.. But however the existing text in the rich text box doesn't
change.. I would the existing text also to change when I change the
language..

For example

when the Input Language Is selected as English(United States) when I press
the keys 1,2,3,4,5,6
I get in the textbox as 123456

when the input language Is selected as French (France) when I press the keys
1,2,3,4,5,6
I get in the textbox as &é"'(-


Now what I require is without manually entering the text everytime. the text
should change according to the language selected..

ie..
123456 should automatically change to &é"'(-


Can anyone help me please.

Thanks In Advance
 
F

Family Tree Mike

Rajkiran R.B. said:
Well I have multiple keyboard layouts installed in my system..

I have written a program in C# such that the required input language can be
selected using the following piece of code

InputLanguage[] lang = new
InputLanguage[InputLanguage.InstalledInputLanguages.Count];

private void Form1_Load(object sender, EventArgs e)
{
richTextBox1.LanguageOption =
RichTextBoxLanguageOptions.AutoKeyboard;
InputLanguage.InstalledInputLanguages.CopyTo(lang, 0);
foreach (InputLanguage l in lang)
{
comboBox1.Items.Add(l.Culture.EnglishName);
}
comboBox1.SelectedIndex =
comboBox1.Items.IndexOf(InputLanguage.DefaultInputLanguage.Culture.EnglishName);
comboBox1.SelectedItem =
InputLanguage.DefaultInputLanguage.Culture.EnglishName;
}

private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
{
InputLanguage.CurrentInputLanguage =
lang[comboBox1.SelectedIndex];
richTextBox1.Focus();
}

So with the above code I could change the language and the change can be
seen when I type.. But however the existing text in the rich text box doesn't
change.. I would the existing text also to change when I change the
language..

For example

when the Input Language Is selected as English(United States) when I press
the keys 1,2,3,4,5,6
I get in the textbox as 123456

when the input language Is selected as French (France) when I press the keys
1,2,3,4,5,6
I get in the textbox as &é"'(-


Now what I require is without manually entering the text everytime. the text
should change according to the language selected..

ie..
123456 should automatically change to &é"'(-


Can anyone help me please.

Thanks In Advance

You would need to convert your current string to the keys that generated it
in the old language, then convert those keys to the string it would create in
the new language.

That said, I don't know how you would get back the keys pressed without
saving them. How do you know 1, 2, 3 was pressed, versus pasting into the UI?
 
R

Rajkiran R.B.

can u please say me how to convert it if I have the keys pressed.. assume
that there will be no txt pasted and all tet will be entered only by keying
it manually
 
R

Rajkiran R.B.

And can anyone say me how record keystrokes..
I had this idea..

Create a queue and in the keypress event of the richtextbox I could write
something like this..

queueobject.Enqueue(e.keyChar);

Will it work....
 
F

Family Tree Mike

Rajkiran R.B. said:
And can anyone say me how record keystrokes..
I had this idea..

Create a queue and in the keypress event of the richtextbox I could write
something like this..

queueobject.Enqueue(e.keyChar);

Will it work....

This seems like a lot of work to just make sure the text agrees with the
keyboard language. I hope that I'm not leading you astray.

To get and store the keys you will need to override the OnKeyPress method in
your form. There you can get the keydata from the keyeventargs object and
keep it in a list<keys>.

To send it back to the control upons language change, you may want to use
SendKeys().

I'm sure there are alternatives.
 
R

Rajkiran R.B.

And can anyone say me how record keystrokes..
I had this idea..

Create a queue and in the keypress event of the richtextbox I could write
something like this..

queueobject.Enqueue(e.keyChar);

Will it work....

can u please say me how to convert it if I have the keys pressed.. assume
that there will be no txt pasted and all tet will be entered only by keying
it manually
 

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