2
tell application "System Events" tell its application process "ControlCenter" tell its menu bar 1 click its menu bar item "User" 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 = "BrilliantCorners" then click btn end if end repeat end tell end tell delay 1 set thePassword to "mypassword" -- Mac user password tell application "System Events" tell process "SecurityAgent" set value of text field 1 of window "Login" to thePassword key code 36 end tell end tell end tell end tell 

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"

This script worked just fine before I upgraded to Monterey, now it's getting stuck for some reason I can't figure out. Any ideas?

2
  • It's getting "stuck" because you're trying to address an invalid object with GUI Scripting. You're going to have to redevelop your script and determine the new reference for the object(s). GUI scripting is brittle, you have no guarantee that from even minor version to minor version, object references do not move. Commented Nov 4, 2021 at 19:52
  • 1
    Any recommendation on how I might determine the new object reference, or where to even start looking? I'm new to scripting and trying to learn how it works. This script is something I pieced together from a few similar scripts I found online - if Monterey changed the object reference and I had to figure out how to incorporate that new reference into the script... well I wouldn't even know where to start looking for that. Any help would be much appreciated. Commented Nov 4, 2021 at 20:40

1 Answer 1

0

In macOS Monterey, using the AppleScript code in your question, I was able to get it to work by removing the tell its group 1 statement and its closing end tell statement, e.g.:

tell application "System Events" tell its application process "ControlCenter" tell its menu bar 1 click its menu bar item "User" end tell tell its window "Control Center" set btns to its buttons repeat with btn in btns if name of btn = "BrilliantCorners" then click btn end if end repeat end tell 

Notes:

The AppleScript code shown herein is just a snippet of your original code and does not show the remaining working code as tested.

2
  • You are an absolute life saver. Pretty sure I even tried that but forgot to delete the corresponding end tell... working perfectly now, thank you very very much Commented Nov 5, 2021 at 19:49
  • I'm having a similar error in getting this previously working Bluetooth Applescript to run on macOS Monterey. Feedback is much appreciated! Commented Nov 10, 2021 at 17:10

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.