Hey Jack,
That script is essentially useless...
This has been done, but I have't seen an update for later versions of macOS.
AppleScript/KM Solution to Toggle the System Preferences “Reduce Transparency” On/OFF Checkbox
Getting it to work in pretty bombproof fashion isn't easy.
I've got this working on macOS 10.14.6 Mojave, but I'm sure it will require adjustments to work on macOS Monterey.
tell application "System Preferences"
if not running then
run
end if
activate
if name of its front window is not "Accessibility" then
reveal pane id "com.apple.preference.universalaccess"
tell pane id "com.apple.preference.universalaccess"
reveal anchor "Seeing_Display"
end tell
end if
end tell
tell application "System Events"
tell application process "System Preferences"
repeat while (get name of window 1) ≠ "Accessibility"
delay 0.1
end repeat
tell window "Accessibility"
tell scroll area 1
tell table 1
set displayPrefs to UI element 1 of rows where its name is "Display"
repeat with i in displayPrefs
if contents of i ≠ missing value then
set displayPrefs to contents of i
end if
end repeat
try
displayPrefs / 0
on error displayPrefRowNum
set AppleScript's text item delimiters to {"«class crow» ", " of «class tabB»"}
set displayPrefRowNum to (text item 2 of displayPrefRowNum) as integer
end try
set displayPrefRow to row displayPrefRowNum
select displayPrefRow
end tell
end tell
tell group 1
tell checkbox "Reduce transparency"
perform action "AXPress"
end tell
end tell
end tell
end tell
end tell
-Chris