Ich versuche, das Diktieren mit Applescript zu aktivieren, und bisher funktioniert Folgendes.
Aber wie lege ich das Dropdown-Menü für die Tastenkombination mit AppleScript fest?
Unten ist der AppleScript-Code:
tell application "System Preferences"
reveal pane id "com.apple.preference.speech"
tell application "System Events"
tell process "System Preferences"
tell window "Dictation & Speech"
tell tab group 1
click radio button "Dictation"
tell radio group 1
if value of radio button "On" is 0 then
click radio button "On"
end if
end tell
end tell
if sheet 1 exists then
tell sheet 1
click button "Enable Dictation"
repeat while sheet 1 exists
end repeat
end tell
end if
end tell
end tell
end tell
quit -- optional
end tell
Die Verwendung des Befehls Shell Defaults in einem Applescript Do Shell-Skript scheint für mich in Ordnung zu sein. Dies erspart GUI-Scripting-Probleme.
Das Skript liest zuerst die Einstellungsdatei. Setzt es dann auf das Gegenteil seines Bool.
set dictionToggle to (do shell script " defaults read ~/Library/Preferences/com.apple.assistant.support \"Dictation Enabled\" ") as integer
do shell script "defaults write ~/Library/Preferences/com.apple.assistant.support \"Dictation Enabled\" -bool " & (not (dictionToggle as boolean)) as Unicode text
Ich sichere immer alle Einstellungsdateien über das Kontextmenü zum Komprimieren von „…“. um eine gezippte Kopie davon zu machen.
Die geänderte Datei com.apple.assistant.support.plist befindet sich in Ihrem Einstellungsordner
/Benutzer/Benutzername/Library/Preferences/ com.apple.assistant.support.plist
Wenn Sie GUI-Scripting verwenden müssen, insbesondere wenn Sie die Tastenkombinationen ändern möchten. ( und da ich nicht Ars sein kann… um herauszufinden, welche der symbolischen Hotkey-Einstellungen in der com.apple.symbolichotkeys.plist die richtige ist)
Dann sollte das funktionieren. (wie zumindest auf meinem Mac :-) )
set off to 1
set fnTwice to 3
set rightCommandTwice to 4
set leftCommandTwice to 5
set eitherCommandTwice to 6
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.speech"
reveal (first anchor of current pane whose name is "Dictation")
end tell
tell application "System Events"
tell application process "System Preferences"
set theGroup to tab group 1 of window "Dictation & Speech"
click radio button "On" of radio group 1 of theGroup
try
click button "Enable Dictation" of sheet 1 of window "Dictation & Speech"
end try
set thePopUp to pop up button 2 of theGroup
click thePopUp
click menu item fnTwice of menu 1 of thePopUp
end tell
end tell
tell application "System Preferences"
--quit
end tell
StrgAltLöschen
Markhunte
Markhunte