AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

How to find out what is the current keyboard layout?

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
twhyman



Joined: 07 Dec 2005
Posts: 218

PostPosted: Wed Oct 31, 2007 9:47 am    Post subject: How to find out what is the current keyboard layout? Reply with quote

Hi,

I am using an english and hebrew keyboard.

is there a way to know what is the current selected language in the language bar? EN or HE?

Thanks
Twhyman
Back to top
View user's profile Send private message
YMP



Joined: 23 Dec 2006
Posts: 265
Location: Russia

PostPosted: Wed Oct 31, 2007 12:26 pm    Post subject: Reply with quote

Code:

F11::
  SetFormat, Integer, H
  WinGet, WinID,, A
  ThreadID:=DllCall("GetWindowThreadProcessId", "Int", WinID, "Int", 0)
  InputLocaleID:=DllCall("GetKeyboardLayout", "Int", ThreadID)
  MsgBox, %InputLocaleID%
Return
Back to top
View user's profile Send private message
twhyman



Joined: 07 Dec 2005
Posts: 218

PostPosted: Wed Oct 31, 2007 1:32 pm    Post subject: Reply with quote

thanks alot for the help Smile

is there a way to also change the layout using dllcall?

thanks
Twhyman
Back to top
View user's profile Send private message
BoBoĻ
Guest





PostPosted: Wed Oct 31, 2007 3:11 pm    Post subject: Reply with quote

Based on that outcome I'd be more than interested to know how to [url]set[/url] the keyboard layout (and set/get additional Regional Settings if possible - to be able to create unattended setups/reconfigurations).

Any help on that would be much appreciated.
Thx for listening. Cool
Back to top
rousni



Joined: 23 Mar 2006
Posts: 41

PostPosted: Wed Oct 31, 2007 6:34 pm    Post subject: Reply with quote

Keyboard layout for a specific window:
Code:
IniRead, BG, %A_ScriptDir%\%1%, TRAFL, BG, 0x00000402
IniRead, EN, %A_ScriptDir%\%1%, TRAFL, EN, 0x00000809
IniRead, FR, %A_ScriptDir%\%1%, TRAFL, FR, 0x0000040C
IniRead, RU, %A_ScriptDir%\%1%, TRAFL, RU, 0x00000419
IniRead, SP, %A_ScriptDir%\%1%, TRAFL, SP, 0x0000040A

      If T = BG
         SendMessage, 0x50, 0, %BG%, Edit1, TRAFL_E
      Else If T = EN
         SendMessage, 0x50, 0, %EN%, Edit1, TRAFL_E
      Else If T = FR
         SendMessage, 0x50, 0, %FR%, Edit1, TRAFL_E
      Else If T = RU
         SendMessage, 0x50, 0, %RU%, Edit1, TRAFL_E
      Else If T = SP
         SendMessage, 0x50, 0, %SP%, Edit1, TRAFL_E


; Keyboard Layout Codes
; ================================================
; [HKEY_CLASSES_ROOT\Mime\Database\Rfc1766]
; [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout\DosKeybCodes]
; "00000402"="bg"
; "00000409"="us"
; "0000040C"="fr"
; "00000419"="ru"
; "00000809"="uk"
Back to top
View user's profile Send private message
YMP



Joined: 23 Dec 2006
Posts: 265
Location: Russia

PostPosted: Thu Nov 01, 2007 6:22 am    Post subject: Reply with quote

I think Edit1 is not needed in the SendMessage commands above. Input locale is a thread characteristic, as you can see from my example, so sending it to the parent window would work as well. Also, using PostMessage seems more reasonable, according to this:
MSDN wrote:

This message is posted, not sent, to the application, so the return value is ignored.

As for other locale features, I have no experience in working with them, so can't help. Rolling Eyes
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1338

PostPosted: Sat Nov 03, 2007 2:45 am    Post subject: Reply with quote

I suppose the global setting, i.e. the one in the Control Panel, is sometimes more useful.

Code:
DllCall("SystemParametersInfo","Uint", 0x0059, "Uint", 0, "UintP", hKL, "Uint", 0)   ; SPI_GETDEFAULTINPUTLANG
MsgBox, % hKL

Code:
hKL := 0x00000409
DllCall("SystemParametersInfo","Uint", 0x005A, "Uint", 0, "UintP", hKL, "Uint", 0)   ; SPI_SETDEFAULTINPUTLANG
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group