In this article, you will see the code for an On-Screen keyboard in Malayalam.
Introduction
When there arose a situation to write an essay in Malayalam, I found it hard to type using a keyboard. So, the idea of On-Screen Keyboard originated there. I had used On-Screen keyboard when my keyboard was not working, so I decided to code an On-Screen keyboard in Malayalam.
Background
When I started to code, I wanted the Unicode code of Malayalam alphabets. I found it at this link.
Using the Code
First of all, I created a New Project with Visual C# - Windows Forms Application, and designed its interface by drag and drop Buttons like below:
Then I gave value to all buttons. The Unicode values can be given to buttons using "\u
" preposition to indicate to the compiler that the value given is Unicode.
Example: Malayalam letter "അ"'s Unicode code is "0D05" and in C# it must be indicated as "\u0D05". The below code gives Unicode values to buttons.
button1.Text = "\u0D05";
button2.Text = "\u0D06";
button3.Text = "\u0D07";
button4.Text = "\u0D08";
button5.Text = "\u0D09";
button6.Text = "\u0D0A";
button7.Text = "\u0D0B";
button8.Text = "\u0D0C";
button9.Text = "\u0D0E";
button10.Text = "\u0D0F";
button11.Text = "\u0D10";
button12.Text = "\u0D12";
button13.Text = "\u0D13";
button14.Text = "\u0D14";
button15.Text = "\u0D3E";
button16.Text = "\u0D3F";
button17.Text = "\u0D40";
button18.Text = "\u0D41";
button19.Text = "\u0D42";
button20.Text = "\u0D43";
button22.Text = "\u0D46";
button23.Text = "\u0D47";
button24.Text = "\u0D48";
button25.Text = "\u0D02";
button26.Text = "\u0D1F";
button27.Text = "\u0D1E";
button28.Text = "\u0D1D";
button29.Text = "\u0D1C";
button30.Text = "\u0D1B";
button31.Text = "\u0D1A";
button32.Text = "\u0D19";
button33.Text = "\u0D18";
button34.Text = "\u0D17";
button35.Text = "\u0D16";
button36.Text = "\u0D15";
button37.Text = "\u0D26";
button38.Text = "\u0D25";
button39.Text = "\u0D24";
button40.Text = "\u0D23";
button41.Text = "\u0D22";
button42.Text = "\u0D21";
button43.Text = "\u0D20";
button44.Text = "\u0D31";
button45.Text = "\u0D30";
button46.Text = "\u0D2F";
button47.Text = "\u0D2E";
button48.Text = "\u0D2D";
button49.Text = "\u0D2C";
button50.Text = "\u0D2B";
button51.Text = "\u0D2A";
button52.Text = "\u0D39";
button53.Text = "\u0D28";
button54.Text = "\u0D27";
button55.Text = "\u0D38";
button56.Text = "\u0D37";
button57.Text = "\u0D36";
button58.Text = "\u0D35";
button59.Text = "\u0D34";
button60.Text = "\u0D33";
button61.Text = "\u0D32";
button62.Text = "\u0D4D";
button72.Text = "\u0D57";
After giving Unicode values to all buttons, we need to code triggering code to capture button click and its actions. In this application, all buttons need the same code to trigger. The action code is:
void buttonClicked(object sender, EventArgs e)
{
Button button = sender as Button;
SendKeys.Send(button.Text);
}
The function "buttonClicked()
" will send the value of Button
to destination. When I click the button whose value is "അ", the function will send the letter "അ" to destination. "SendKeys.Send()
" function is used to send the value to destination. It makes the same effect that we have pressed key "അ" in keyboard.
Now the action code is ready. Now we want to add this action to all buttons in application.
The class "EventHandler
" is used to add the action function to buttons.
button1.Click += new EventHandler(buttonClicked);
button2.Click += new EventHandler(buttonClicked);
button3.Click += new EventHandler(buttonClicked);
button4.Click += new EventHandler(buttonClicked);
button5.Click += new EventHandler(buttonClicked);
button6.Click += new EventHandler(buttonClicked);
button7.Click += new EventHandler(buttonClicked);
button8.Click += new EventHandler(buttonClicked);
button9.Click += new EventHandler(buttonClicked);
button10.Click += new EventHandler(buttonClicked);
button11.Click += new EventHandler(buttonClicked);
button12.Click += new EventHandler(buttonClicked);
button13.Click += new EventHandler(buttonClicked);
button14.Click += new EventHandler(buttonClicked);
button15.Click += new EventHandler(buttonClicked);
button16.Click += new EventHandler(buttonClicked);
button17.Click += new EventHandler(buttonClicked);
button18.Click += new EventHandler(buttonClicked);
button19.Click += new EventHandler(buttonClicked);
button20.Click += new EventHandler(buttonClicked);
button22.Click += new EventHandler(buttonClicked);
button23.Click += new EventHandler(buttonClicked);
button24.Click += new EventHandler(buttonClicked);
button25.Click += new EventHandler(buttonClicked);
button26.Click += new EventHandler(buttonClicked);
button27.Click += new EventHandler(buttonClicked);
button28.Click += new EventHandler(buttonClicked);
button29.Click += new EventHandler(buttonClicked);
button30.Click += new EventHandler(buttonClicked);
button31.Click += new EventHandler(buttonClicked);
button32.Click += new EventHandler(buttonClicked);
button33.Click += new EventHandler(buttonClicked);
button34.Click += new EventHandler(buttonClicked);
button35.Click += new EventHandler(buttonClicked);
button36.Click += new EventHandler(buttonClicked);
button37.Click += new EventHandler(buttonClicked);
button38.Click += new EventHandler(buttonClicked);
button39.Click += new EventHandler(buttonClicked);
button40.Click += new EventHandler(buttonClicked);
button41.Click += new EventHandler(buttonClicked);
button42.Click += new EventHandler(buttonClicked);
button43.Click += new EventHandler(buttonClicked);
button44.Click += new EventHandler(buttonClicked);
button45.Click += new EventHandler(buttonClicked);
button46.Click += new EventHandler(buttonClicked);
button47.Click += new EventHandler(buttonClicked);
button48.Click += new EventHandler(buttonClicked);
button49.Click += new EventHandler(buttonClicked);
button50.Click += new EventHandler(buttonClicked);
button51.Click += new EventHandler(buttonClicked);
button52.Click += new EventHandler(buttonClicked);
button53.Click += new EventHandler(buttonClicked);
button54.Click += new EventHandler(buttonClicked);
button55.Click += new EventHandler(buttonClicked);
button56.Click += new EventHandler(buttonClicked);
button57.Click += new EventHandler(buttonClicked);
button58.Click += new EventHandler(buttonClicked);
button59.Click += new EventHandler(buttonClicked);
button60.Click += new EventHandler(buttonClicked);
button61.Click += new EventHandler(buttonClicked);
button62.Click += new EventHandler(buttonClicked);
button72.Click += new EventHandler(buttonClicked);
The function "buttonClicked()
" added as common Click Mouse action trigger to all buttons.
Now we can type Malayalam letters using this application. But the value of clicked button receives the application itself. So we can type any other places using this application. We need to inactivate this application always. If we do so, we can type the Malayalam letters in active windows. The code to inactivate the window is below:
protected override CreateParams CreateParams
{
get
{
CreateParams param = base.CreateParams;
param.ExStyle |= 0x08000000;
return param;
}
}
Now, the window of our application is always inactive and we can type Malayalam letters to active application.
But the new problem is that active window can overlap our application. So we need to drag our application always to set a good position to see both active application and our Keyboard application. So It is better to make our application 'Always Top'. We can apply this property using "Property" box of form by making "TopMost" property "true
".
Yes, now our application will always be on top and is always inactive. So we can type Malayalam letters easily.
Hope you liked this article. Thank you for reading.
History
- 2nd June, 2014: Initial version