Friday, August 1, 2014

#1 2005-12-22 08:54:49 am

suzanna_h
Member
Registered: 2005-12-22
Posts: 4

Using applescript to change the keyboard layout

How do I use applescript to change the keyboard layout (as if I had done it through System Preferences), or is there a shell command I can use in the script?

Offline

 

#2 2005-12-22 09:07:10 am

Bruce Phillips
Administrator
Registered: 2004-07-15
Posts: 2649

Re: Using applescript to change the keyboard layout

I'd look here first: http://bbs.applescript.net/viewtopic.php?id=15339

That will turn on all the keyboard layouts. After a few changes, you might end up with this:

Applescript:

tell application "System Preferences"
   activate
   set current pane to pane id "com.apple.Localization"
   reveal (first anchor of current pane whose name is "InputMenu")
end tell

tell application "System Events"
   launch
   tell window 1 of process "System Preferences"
       tell row 38 of table 1 of scroll area 1 of tab group 1
           --row 38 is Australian
           select
           click checkbox 1
       end tell
   end tell
end tell

--quit application "System Preferences"

If you want to turn on multiple layouts, then try something like this:

Applescript:

tell application "System Preferences"
   activate
   set current pane to pane id "com.apple.Localization"
   reveal (first anchor of current pane whose name is "InputMenu")
end tell

tell application "System Events"
   launch
   tell window 1 of process "System Preferences"
       repeat with rowNumber in {47, 48} -- “Canadian” and “Canadian French - CSA”
           tell row rowNumber of table 1 of scroll area 1 of tab group 1
               select
               click checkbox 1
           end tell
       end repeat
   end tell
end tell

--quit application "System Preferences"


Filed under: System

Offline

 

#3 2006-02-22 03:30:56 am

seszi
Member
Registered: 2006-02-22
Posts: 1

Re: Using applescript to change the keyboard layout

these are enabling new layouts, but how to change between the active layouts?

former times, in os9, the simple:

Applescript:

set keyboard layout to "U.S."

worked...

anything like this for osx?

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.088 seconds, 8 queries executed ]

RSS (new topics) RSS (active topics)