Can any AppleScript/Accessibility gurus with Ventura figure out how to do the Fast User Switch?
Note that this assumes the System Settings have the for Control Center with Fast User Switching showing the Full Name in the menu bar.
The code for Monterey is essentially:
set n to "Full Name"
set good to false
tell application "System Events"
if n is not full name of current user then
tell the front menu bar of process "ControlCenter"
set mbis to menu bar items
repeat with mExtras from 1 to the length of mbis
try
if value of attribute "AXIdentifier" of item mExtras of mbis is "com.apple.menuextra.user" then
tell menu bar item mExtras
click
set good to true
end tell
exit repeat
end if
end try
end repeat
end tell
if good then
tell process "ControlCenter"
click button n of front window
end tell
end if
else
"Cant switch to current user"
end if
end tell
The click button fails for three reasons, one easy, one workable, and one I can't figure out.
Second (yes, out of order), the window now takes some time to appear, so a delay is needed before the if good then
. Not ideal, but ok.
First, the buttons are back within a group, so it would be:
click button n of group 1 of front window
But the part I cannot figure out is that button "Full Name"
no longer works.
Accessibility Inspector can see the Label on the button is "Full Name", but button "Full Name"
does not work, and nothing I have found will read the name from the button (eg description of button 1
).
Any ideas?