I have the following AppleScript that's supposed to automatically switch to the Administrator user. It worked in Big Sur, but isn't working in Monterey.
tell application "System Events"
tell its application process "ControlCenter"
tell its menu bar 1
click its menu bar item "barmar"
end tell
tell its window "Control Center"
tell its group 1
set btns to its buttons
repeat with btn in btns
if name of btn = "Administrator" then
click btn
end if
end repeat
end tell
end tell
end tell
end tell
It gets the following error:
System Events got an error: Can’t get group 1 of window "Control Center" of application process "ControlCenter". Invalid index."
number -1719 from group 1 of window "Control Center" of application process "ControlCenter"
The list of users is popping up, but it's failing on "tell its group 1".