如何在 Mac OS X 上自动或以编程方式更改系统偏好设置
我正在尝试找出如何以编程方式更改 Mac OS X 上的系统首选项设置。如果不可能,请创建一些安装后自动化脚本(使用 Apple 脚本或其他方式)并将其作为安装程序的一部分运行。我对更改“语言和文本”设置特别感兴趣,这些设置是系统偏好设置中“个人”设置的一部分。
以下是对我的问题的更多描述:
我正在尝试为我为 Mac OS X 编写的自定义键盘布局创建一个安装程序。键盘布局基本上允许人们将 ASCII 键盘输入音译为外文字母。 Mac OSX* 上不存在外语。我能够使用 Apple 的 PackageMaker 创建一个基本安装程序,将所有必需的文件(.keylayout 文件、图标和自定义字体)转储到目标计算机中各自的目录中。但在选择和使用键盘布局之前,需要在系统偏好设置中配置一些个人设置。我想在安装过程中为用户自动配置这些“一次性”设置。是否可以使用 Cocoa/Objective-C 更改设置。如果没有,我希望您帮助我如何使用 Apple 脚本来自动配置。如果可能,请包含一些示例代码或示例指针。谢谢。
以下是系统偏好设置中需要配置的设置
- 选择系统偏好设置 -->语言与文本 - 输入源
- 从列表中选择“语言名称”
- 单击“键盘快捷键”并启用“选择上一个输入源”和“选择输入菜单中的下一个源”。
- 双击快捷方式组合“⌘ space”并将其更改为“⌘ L”(“选择上一个输入源”)和“ctrl⌘L”(“选择输入菜单中的下一个源”)
- 退出系统首选项。完成
注意: *系统语言无需更改。仅输入源(键盘布局)。
I am trying to figure out how to programmatically change System Preference settings on the Mac OS X. If that is not possible, create some post-installation automation script (using Apple Script or other means) and run it as part of the installer. I am particularly interested in making changes to the "Language & Text" settings which are part of the "personal" settings in System Preferences.
Here is more description of my problem:
I am trying to create an installer for a custom keyboard layout I wrote for Mac OS X. The keyboard layout basically allows people to transliterate ASCII keboard input to foreign letters. The foreign language does not exist on Mac OSX*. I was able to use Apple's PackageMaker to create a basic installer that dumps all the necessary files (.keylayout file, icons and the custom fonts) in their respective directories in the target computer. But there are a couple of personal settings that need to be configured in System Preferences before the keyboard layout can be selected and used. I would like to auto-configure these "one-time" settings for the user during the installation process. Is it possible to make changes to the settings using Cocoa/Objective-C. If not, I would like your help on how I can use Apple Script to automate the configuration. Please include some sample code or pointers to examples if possible. Thank you.
Here are the settings that need to be configured on System Preferences
- Select System Preferences --> Language & Text -- Input Sources
- Select "The Language Name" from the list
- Click on "Keyboard Shortcuts" and enable "Select the previous input source" and "Select next source in Input Menu".
- Double click on the shortcut combinations "⌘ space" and change them to "⌘ L" for the "Select the previous input source" and "ctrl⌘L" for "Select next source in Input Menu"
- Exit systems preference. Done
NB: *The system language need not be changed. Only the input source (keyboard layout).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
请参阅
NSUserDefaults
。您要设置的值可能位于 NSGlobalDomain 中。See
NSUserDefaults
. The values you want to set are probably inNSGlobalDomain
.