Help - Search - Members - Calendar
Full Version: Autoswitch Keyboard layout in C# program
OmicronLab Community > Avro Keyboard - Unicode Compliant Free Bangla Typing Software > Get Support for Avro Keyboard
jumper1
Hi,



Say I have 4 textboxes in a C# program. 2 of them take Bangla input and the other two English input. How can make C# autoswitch the keyboard layout to Bangla when the cursor is at a Bangla textbox and autoswitch to English when the cursor is at a English textbox.



I am not sure but maybe sending Alt+Ctrl+B to console (have't tried yet) will work but then say if someone is at a English textbox and prossed Alt+Ctrl+B to change to Bangla layout. if he then goes to a Bangla textbox then it will be automatically changed to English as the program sends Alt+Ctrl+B. What I am looking for is to change to the exact Bangla/English layout irrespective of the current keyboard layout.



Any help will be appreciated.



Thanks



Mehdi Hasan
I don't think it is possible at this moment, because Avro Keyboard is designed to ignore "generated keystrokes", Avro only "listen and modify" actual keystrokes pressed by user to bypass several problems.

However, you can still try sending F12 using windows low level API calls, if Avro catches that, then the rest of the part is easy, you will just check the current locale of your C# application and change the keyboard mode as needed.


-----------------------------------------------------------------------

I just got a new idea from your topic. We can make some API/method for Avro Keyboard so that developers can integrate their application at some level ad automate some of the functions of Avro Keyboard. It may be a server (Avro)- client (your C# program) based architecture. Wait, may be these things will come at future smile.gif
jumper1
Adding API seems like a great idea. I am sure more developers will request it as more Bangla progams are developed. I will try and see if F12 thing works.

Thanks
jumper1
QUOTE(Mehdi Hasan @ Aug 26 2007, 09:11 AM) *
I don't think it is possible at this moment, because Avro Keyboard is designed to ignore "generated keystrokes", Avro only "listen and modify" actual keystrokes pressed by user to bypass several problems.

However, you can still try sending F12 using windows low level API calls, if Avro catches that, then the rest of the part is easy, you will just check the current locale of your C# application and change the keyboard mode as needed.


-----------------------------------------------------------------------

I just got a new idea from your topic. We can make some API/method for Avro Keyboard so that developers can integrate their application at some level ad automate some of the functions of Avro Keyboard. It may be a server (Avro)- client (your C# program) based architecture. Wait, may be these things will come at future smile.gif


But you know the problem is that if I am having to uncheck the "change locale" option in th Avro settings to avoid the "culture ID 2117 not supported" exception that any Visual Studio 2005 program throws. And without checking that I dont think the locale changes and remains 1033 (English) even if I change the layout from English to Avro Bangla.
Mehdi Hasan
I believe "culture ID 2117 not supported" exception doesn't occur in VS 2005 if you use Bangla (India) locale. Have you tried that?
jumper1
Thanks. Yes that works.

I have been able to detect the current keybaord layout using my C# code but sending the F12 to Avro has failed so far. I have tried normal SendInput, I have tried sending it using Win32 API user32.dll SendInput. In all case Avro seems to ignore the F12. I even wrote a keyboard hook in C# and it seems my hook gets all keystokes except F12 as if Avro is eating the F12 up and not passing it to the next hook? How exactly are you checking the keystrokes?

Any help will be appreciated.

Thanks
Mehdi Hasan
QUOTE
How exactly are you checking the keystrokes?


That's the real problem now!

Avro checks LLKHF_INJECTED flag in the hook procedure to be sure that the pressed/released action has been done in physical keyboard. When its value is true, Avro just ignore that key to avoid any never ending loop which may occur for a key press/release action produced by Avro.

Check whether you can produce a keystroke without having LLKHF_INJECTED flag (which seems to be impossible), then Avro will catch it.
jumper1
Hi,



I sent you a private message. Please read and respond as soon as possible.



Thanks

Mehdi Hasan
Its ready smile.gif
Please check PM for download link.
Bangla Bhai
Mehdi Bhai,
Command line will be easier than API...

avrokeyboard.exe /b
avrokeyboard.exe /b /unibijoy
avrokeyboard.exe /b /unibijoy /o
avrokeyboard.exe /b /unibijoy /o /s
avrokeyboard.exe /b /phonetic
avrokeyboard.exe /b /phonetic /d
avrokeyboard.exe /e

/b = Bangla
/e = English
/o = Old Style
/d = Dictionary Support
/s = Silent Mode

In Silent Mode, you can hook the Current Screen & change its title to "Current Title (Powered by AVRO)" smile.gif

"Document1 - Microsoft Word (Powered by AVRO)" biggrin.gif

But, API is better & complex solution...
Mehdi Hasan
There may be several approach.

1. The command line one you said. But it will not work if Avro is already running (unless we implement custom message sending/receiving method between two instances, after sending message, the newer instance will exit). It will be problematic for two way communication.

2. Only message sending based approach. It will be also problematic for two way communication unless the external application implement a listener.

2. API. Returning value is easy, but for truly two way communication we have to implement callback routines in C/C++. I don't want to go through this because its complexity.

3. Socket & client/server based approach. it will be easy for external apps to communicate with Avro, will be truly two way communication, but the response may be slow because of more latency.

4. ActiveX Exe/dll & plugin based approach. Easer to implement, specially in VB, but may be hardsome in other languages.


Let me think. If we enable such external commands, we also need to add security options to let user choose which applications can control Avro, otherwise it will be easy to build a malicious program which may interrupt and cause problems.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.