以编程方式获取/设置 Mac OSX 默认系统键盘快捷键
我正在尝试找到一种方法来以编程方式获取/设置系统偏好设置 -> 中找到的默认 OSX 系统键盘快捷键(热键)。 键盘& 鼠标-> 键盘快捷键选项卡。 我需要能够在后台执行此操作,因此 GUI 脚本不是解决方案。
我无法找到 plist 或任何可能存储此信息的内容。 我尝试在使用系统偏好设置时使用仪器“文件活动”跟踪,但再次空手而归。
任何帮助表示赞赏。
I'm trying to find a way to programatically get/set the default OSX system keyboard shortcuts (hotkeys) found in the System Preferences -> Keyboard & Mouse -> Keyboard Shortcuts tab. I need to be able to do this in the background, so GUI scripting is not a solution.
I'm unable to find a plist or anything where this info might be stored. I tried using Instruments "File Activity" trace while using System Preferences, but again came up empty handed.
Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上有一个 Plist,信息存储在 com.apple.symbolichotkeys AppleSymbolicHotKeys 中,这是一个复杂的嵌套字典和列表:
假设您想以编程方式修改系统中的“显示帮助菜单”快捷方式首选项-> 键盘-> 快捷方式选项卡 -> 应用程序快捷方式 -> 所有应用程序。 要找到正确的条目,请打印文本文件中的所有 Plist,请修改系统偏好设置中的快捷方式,再次打印第二个文件中的 Plist 并比较它们:
因此要修改的条目是
98
,因为它是一个复杂的结构,您必须使用/usr/libexec/PlistBuddy
来完成它:注意:
bool
> 要修改参数,Actually there's a Plist for that, informations are stored in
com.apple.symbolichotkeys AppleSymbolicHotKeys
which is a complex nested dicts and lists as :Let's say you want to programatically modify the "Show Help Menu" shortcut in System Preferences -> Keyboard -> Shortcuts tab -> App Shortcut -> All Applications. To find the correct entry print all the Plist in a text file, modify the shortcut in the System Preferences, print again the the Plist in a second file and diff them:
So the entry to be modified is
98
, since it's a complex structure you'll have to use/usr/libexec/PlistBuddy
to do it:Note:
bool
parameter in order to modify it哎呀,我重新运行了 Instruments,但这次确保关闭了系统偏好设置,直到那时才写出快捷方式。
事实证明该文件位于 ~/Library/Preferences/com.apple.symbolichotkeys.plist
但它非常神秘。 尽管如此,这就是我所追求的。
Ooop, I re-ran Instruments, but made sure to close out System Preferences this time, the shortcuts weren't getting written out until then.
Turns out the file is located at ~/Library/Preferences/com.apple.symbolichotkeys.plist
But it's pretty cryptic. None the less, this is what I was after.