r/applescript • u/CounterBJJ • Oct 24 '22
AppleScript to change spelling language no longer working after upgrade to Ventura
Hello,
u/ChristoferK was kind enough to write me a script to toggle the spelling language between US English and French. Unfortunately, after upgrading to Ventura, Shortcuts is giving me the following error message:
System Settings got an error: AppleEvent handler failed.
The script is:
property language : {en_us:"U.S. English", fr:"Français", auto:"Automatic By Language", default:a reference to my language's fr, alternate:a reference to my language's en_us}
property toggle : contents of my language's {default, alternate}
to wait for _UIElement
tell application id ("com.apple.systemevents") ¬
to repeat 20 times -- 10 seconds
if the _UIElement exists then return
delay 0.5
end repeat
error "Timeout." from _UIElement
end wait
tell application id "com.apple.systempreferences" to reveal ¬
anchor "Text" of pane id "com.apple.preference.keyboard"
tell application id ("com.apple.systemevents") to tell (process 1 ¬
where its bundle identifier = "com.apple.systempreferences") ¬
to tell the front window to tell (a reference to tab group 1's ¬
pop up button 3)
my (wait for it)
click it
set bool to 1 - ((the value = toggle's item 1) as integer) * 2
tell (a reference to menu 1)
my (wait for it)
pick the menu item named (toggle's item index bool)
end tell
log the value as text
end tell
tell application id "com.apple.systempreferences" to quithoping someone can help making it work in Ventura.
Thanks in advance.
3
Upvotes
View all comments
Show parent comment
1
u/CounterBJJ Oct 26 '22 edited Nov 05 '22
Hello,
Thank you for your continued input. Yes, the the app is now called System Settings, though its bundle identifier seems to be the same as
returns "com.apple.systempreferences"
Out of the three scriptability tests you provided, only the top one returns a meaningful result. By default, it opens the Appearances tab and returns {"Appearance"}.
If you click on another tab and run the script again, it returns that tab's name (ex: {"Keyboard"} for the keyboard tab).
The other two scripts produce the same error message:
error "System Settings got an error: AppleEvent handler failed." number -10000.
I guess I will have to be patient and see if meaningful solutions are found in the following weeks and months.
EDIT: I did some research and found that the keyboard pane id in Ventura is <com.apple.Keyboard-Settings.extension>. It can be opened in Terminal with