r/applescript • u/FlexibleFuture • Nov 15 '22
Reset zoom to pinch script not working after Ventura Update. Any help appreciated.
I keep getting System Settings got an error: AppleEvent handler failed.
on run {input, parameters}
`tell application "System Settings"`
`if it is running then`
`quit`
`delay 0.2`
`end if`
`end tell`
`tell application "System Settings" to reveal pane id "com.apple.preference.trackpad"`
`tell application "System Events"`
`tell front window of application process "System Preferences"`
`repeat until (exists checkbox 2 of tab group 1)`delay 0.01
`end repeat`
`click checkbox 2 of tab group 1`
`click checkbox 2 of tab group 1`
`end tell`
`end tell`
`quit application "System Settings"`
`return input`end run
2
Upvotes
1
u/the_entertainment96 Dec 16 '22 edited Dec 16 '22
If you're still looking for a solution, this script should work! I based the first part (looping through the row indices to find the correct Trackpad row) on this really helpful thread: https://www.reddit.com/r/applescript/comments/ykpinw/macos_ventura_system_settings_with_system_events/
The rest is just navigating through Ventura's awful System Events UI, whose hierarchy is maddeningly unintuitive.
Anyway, here's the script! It closes System Events if already open, then finds the correct Trackpad row, selects it, then finds the correct Trackpad window (whose name changes if you have a Magic Trackpad connected), navigates to the Scroll & Zoom tab, and toggles the "Zoom in or out" checkbox. The script takes about 6.5 seconds on my machine (Macbook Pro 13' 2019); you may want to adjust the delays, although, at least for me, System Events takes forever to load, and if there's an update to download, it takes a few extra milliseconds to populate, which can alter the row indices. Good luck!
1
u/fisher2nz Mar 24 '23
It's such a disappointment since touch pad is Apple's territory yet such major bug is not fixed, for such a long time. And the problem recreates itself every 3 minutes.