In a OSX Cocoa app, I would like a button that would open the "speech" preference pane. Is that possible? I'm just trying to save them the time to go System Preferences > Speech > Text to Speech
相关问题
- Xcode debugger displays incorrect values for varia
- Is there a way to report errors in Apple documenta
- Advice for supporting both Mac and Windows Desktop
- Avoid cmake to add the flags -search_paths_first a
- NSOutlineView drag line stuck + blue border
相关文章
- 现在使用swift开发ios应用好还是swift?
- Visual Studio Code, MAC OS X, OmniSharp server is
- xcode 4 garbage collection removed?
- IntelliJ IDEA can't open projects or add SDK o
- Automator: How do I use the Choose from List actio
- ImportError: No module named twisted.persisted.sty
- How can I vertically align my status bar item text
- Converting (u)int64_t to NSNumbers
The following is a fairly easy (and reliable) way to at least get System Preferences open to the Speech.prefPane:
However, it won't necessarily be switched to the
Text to Speech
tab, but rather the last tab the user had selected.It is possible to actually switch to the Text to Speech tab as well, but it's a bit more involved. You can use AppleScript to send commands to the System Preferences application, but using the
ScriptingBridge.framework
(See Scripting Bridge Programming Guide) is much faster.You'll need to add the
ScriptingBridge.framework
to your project, and then use a command like the following in Terminal to generate aSBSystemPreferences.h
header file to work with:sdef "/Applications/System Preferences.app" | sdp -fh --basename SBSystemPreferences -o ~/Desktop/SBSystemPreferences.h
Add that
SBSystemPreferences.h
header to your project, then change-openSpeechPrefs:
to the following:EDIT:
Sample project using the ScriptingBridge.framework method: http://github.com/NSGod/OpenSystemPrefsTTS
For the guys who run into the same issue that I mentioned in the comment, just go to the
~/Desktop
(cos I specify this position) and you'll see theSBSystemPreferences.h
has been created.However, in this header, some class declarations are missing. So you have to add this declarations explicitly.
In my case, class "item" is undefined. So add this:
@class SBSystemPreferencesItem;
Then compile it and see what's still missing, which declaration needs to be added.
Credits go to following site: https://macosxautomation.com/system-prefs-links.html
List of URLs for reference: