?

Log in

Applescript to modify Modifier keys. - applescript [entries|archive|friends|userinfo]
applescript

[ website | Apple's AppleScript Home Page ]
[ userinfo | livejournal userinfo ]
[ archive | journal archive ]

Applescript to modify Modifier keys. [Apr. 10th, 2009|05:51 pm]
applescript

applescript

[scavgraphics]
I'm trying to make an applescript to toggle the caps lock on and off in the "Modifier Keys" section of the Keyboard & Mouse control panel.

As I'm researching if this is possible, I keep running into GUI scripting.

Do you actually need to have it open dialogs and click buttons to modify system preferences? There's not just a bit of code or flag that can get easily flipped?
linkReply

Comments:
[User Picture]From: xv
2009-04-10 11:56 pm (UTC)
You might be able to do it with man defaults, let me look. Otherwise yeah the System Preference dictionary is weak, and you'll need GUI to go the last mile for you. I've done it before if you're interested.
(Reply) (Thread)
[User Picture]From: xv
2009-04-11 12:09 am (UTC)
set x to 1
tell application "System Preferences"
activate
reveal anchor "keyboardTab_ModifierKeys" of pane id "com.apple.preference.keyboard"
end tell
delay x
tell application "System Events" to tell 1st sheet of window "Keyboard & Mouse" of process "System Preferences"
tell 4th pop up button
click
click menu item "No Action" of front menu
end tell
delay x
click button "OK"
end tell
delay x
tell application "System Preferences" to quit
(Reply) (Parent) (Thread)
[User Picture]From: xv
2009-04-11 12:13 am (UTC)
...by the way, you can comment out the activate line and it will run properly in the background, I just had that to test the delays.
(Reply) (Parent) (Thread)
[User Picture]From: scavgraphics
2009-04-11 01:57 am (UTC)
I'll try it out..thanks!

(This is something I'm trying to put together for a friend after Automator has failed in the same trick, so we'll see:) )
(Reply) (Parent) (Thread)
From: (Anonymous)
2010-09-12 11:57 pm (UTC)

Me too! No luck.

Apparently it is the holy grail. I have noticed that log in dialogs can tell you whether caps lock is on or not with a little icon at the right of a password field. I also would like a "set caps lock to off" or "on" command of some sort. Why is this apparently so difficult???????
(Reply) (Thread)