If I go to System Preferences, Keyboard, Keyboard Shortcuts, then Application Shortcuts, I can define custom shortcuts to be used on a Mac.
Any way to access this functionality via Applescript?
On your Mac, choose Apple menu > System Preferences, then click Keyboard . Click Change Keyboard Type, then follow the onscreen instructions.
Create a keyboard shortcutOn the Tools menu, select Customize Keyboard. In the Categories list, select a tab name. In the Commands list, select the command that you want to assign a keyboard shortcut to. Any keyboard shortcuts that are currently assigned to the selected command will appear in the Current keys box.
The shortcuts are stored in NSUserKeyEquivalents dictionaries in ~/Library/Preferences/.GlobalPreferences.plist and the property lists of applications.
defaults write -g NSUserKeyEquivalents -dict-add Duplicate '~@d' Minimize '\0'
defaults write com.apple.finder NSUserKeyEquivalents '{"Show Package Contents"="@\r";}'
The shortcut format is described in the Cocoa Text System article.
System Preferences isn't scriptable with Applescript natively, you have to interact with it by GUI Scripting. GUI Scripting is really a last resort that allows you to interact with controls by explicitly declaring and calling them, and it doesn't take much to throw off a GUI script. It is difficult to implement even for experienced Applescript programmers. You'll find a few introductory tutorials out there in the web, but not much else.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With