Script stopped working after 10.15.4 update

I have simple scripts to turn down the brightness of my MacBook via an AppleScript. This worked fine in Catalina 10.15.3, but has stopped working after I upgraded to 10.15.4.


The script is as follows:


tell application "System Preferences"
reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays"
end tell
tell application "System Events" to tell process "System Preferences" to tell window "Built-in Retina Display"
set value of value indicator 1 of slider 1 of group 1 of tab group 1 to 0.0
end tell

..error is as follows:

error "System Events got an error: Can’t get slider 1 of group 1 of tab group 1 of window
\"Built-in Retina Display\" of process \"System Preferences\". Invalid index." number -1719
from slider 1 of group 1 of tab group 1 of window "Built-in Retina Display" of process "System Preferences"

Accepted Reply

GUI Scripting is inherently sensitive to changes in application interfaces from version to version. In your case, the Built-in Retina Display window in System Preferences lost the "group 1" UI Element in macOS Catalina 10.15.4. So you should be able to fix the problem by changing the 'set value' line of your script to 'value indicator 1 of slider 1 of tab group 1'. I have not tested this, but my UI Browser application shows this to be the new element path.

Replies

GUI Scripting is inherently sensitive to changes in application interfaces from version to version. In your case, the Built-in Retina Display window in System Preferences lost the "group 1" UI Element in macOS Catalina 10.15.4. So you should be able to fix the problem by changing the 'set value' line of your script to 'value indicator 1 of slider 1 of tab group 1'. I have not tested this, but my UI Browser application shows this to be the new element path.

That worked perfectly. Thanks for your help.


For future reference, how do I determine what an element path is?

You can download the 30-day free trial of my UI Browser application here: https://pfiddlesoft.com/uibrowser/index.html


A free alternative is Apple's Accessibility Inspector application, included in Xcode. But it is much harder to use and does not provide AppleScript indexes or, in some cases, specialized AppleScript terminology.


You can also write scripts that explore the parent and children of each element in the path, one by one, but that is very time consuming.