How to get the current Keyboard layout?

Hello everyone
I’m new to AppleScript but trying to learn it. I’ve some question that stuck for hours.
I’d like to get the “current keyboard layout” and return the value. (to QuicKeys exactly.) My action step in QK needs to check the current keyboard layout. If it is “U.S.” it should not work and so on.
I’m using Mac OS X 10.5.2.
Please guide me :-?
Jedt S.


try this

set MACaddress to (primary Ethernet address of (system info))
set {TID, text item delimiters} to {text item delimiters, ":"}
set MACaddress to text items of MACaddress
set text item delimiters to TID
set MACaddress to MACaddress as text
set text item delimiters to TID

set pListPath to (path to preferences folder as text) & "" & MACaddress & ".plist"

tell application "System Events"
	set a to value of property list item "KeyboardLayout Name" of property list item 1 of property list item "AppleSelectedInputSources" of contents of property list file pListPath
end tell
display dialog a

Hello, StefanK
It’s working like charm! How on earth for me to know it has to deal with MAC address and Apple’s HIToolbox? Ha ha… Seems like AS is a bit long road for newbie who hasn’t program on Mac before :wink:
Btw, I’m very please and would like to thank you from my heart. :slight_smile: it’s one more step ahead for me to live happily with Mac + QK.!
Best Regards
Jedt S.