
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comfort Software :: Forums :: Development | |||
|
|||
Programmaticaly change keybaord language |
| Author | Post |
| chell |
| ||
![]() Joined: Fri Jul 03 2009, 04:30am Posts: 1 | Hi, How can I change programmaticaly the keybaord language (like with the language bar by clicking with the mouse). I'm using .NET/C#. Currently I can Show/Hide/Toggle ... the keyboard whithout any problem. Thanks Christophe | ||
| Back to top |
| Comfort |
| ||
![]() ![]() ![]() Joined: Wed Sep 19 2007, 03:42pm Posts: 600 | Try message WM_INPUTLANGCHANGEREQUEST. Like: SendMessage(GetForegroundWindow, WM_INPUTLANGCHANGEREQUEST, 0, NewHKL) Have a nice day | ||
| Back to top |
| PVitt |
| ||
![]() Joined: Tue May 17 2011, 07:41am Posts: 5 | Hello, Just an example, problem occurs with all langauges: I have the portugese (Brasil) language file (pt.txt) in the Lang folder. When I post the appropriate language ID (1046) as you described above, the language bar switches to Portugese (Brasil), but the keyboard layout doesn't change. When I then click on the language bar, it stays on Purtugese (Brasil) and changes the keyboard layout. But I want to change the Kexboard layout without having the user to use the language bar. Where is my mistake? Thanks in advance, Peter | ||
| Back to top |
| Comfort |
| ||
![]() ![]() ![]() Joined: Wed Sep 19 2007, 03:42pm Posts: 600 | Try to use full Langauage ID. You can find Language ID in field Options -> Keys -> Show keyboard layout by default. Hexadecimal Language ID for Portugese (Brasil) is 0xF0100416 But some applications don't support message WM_INPUTLANGCHANGEREQUEST. Have a nice day | ||
| Back to top |
| PVitt |
| ||
![]() Joined: Tue May 17 2011, 07:41am Posts: 5 | Thanks for the quick reply, but this also doesn't work. Neither 0xF0100416 nor 0x04160416 as statet at "Options -> Keys -> Show keyboard layout by default" does the trick. Here is the code I use:
[DllImport( "user32.dll", EntryPoint = "FindWindow" )]
| ||
| Back to top |
| Comfort |
| ||
![]() ![]() ![]() Joined: Wed Sep 19 2007, 03:42pm Posts: 600 | This is incorrect code! You have to send message WM_INPUTLANGCHANGEREQUEST to foreground window: SendMessage(GetForegroundWindow, WM_INPUTLANGCHANGEREQUEST, 0, NewHKL) Have a nice day | ||
| Back to top |
| PVitt |
| ||
![]() Joined: Tue May 17 2011, 07:41am Posts: 5 | Thanks. That was the error I made. Here is the code that works:
[DllImport( "user32.dll" )]
| ||
| Back to top |
| Moderators: Comfort |