@@ -44,8 +44,60 @@ const enableFocusModeVenturaAppleScript = (
4444 // TODO: attempt to rewrite scripts without any locale specific instructions
4545 // so this setup can be used regardless of user locale preferences.
4646 const center = locale . trim ( ) === "en_GB" ? "Centre" : "Center" ;
47- const checkboxPosition =
48- platformMajor < 25 ? "checkbox 2 of group 1" : "checkbox 6 of group 1" ;
47+
48+ if ( platformMajor >= 25 ) {
49+ return `-- Startup delay to reduce chance of "Application isn't running (-600)" errors
50+ delay 1
51+
52+ set timeoutSeconds to 30.0
53+
54+ tell application "System Events"
55+ -- open Control Center using the same keystroke used in your script
56+ key down 63
57+ keystroke "c"
58+ delay 0.3
59+ key up "c"
60+ key up 63
61+ delay 0.5
62+ try
63+ tell application process "Control Center"
64+ set root to window 1
65+ my dumpElements(root, 0)
66+ end tell
67+ on error errMsg
68+ log "ERROR: " & errMsg
69+ end try
70+ end tell
71+
72+ on dumpElements(el, indent)
73+ try
74+ set r to (role of el) as string
75+ on error
76+ set r to ""
77+ end try
78+ try
79+ set n to (name of el) as string
80+ on error
81+ set n to ""
82+ end try
83+ try
84+ set idx to (index of el) as string
85+ on error
86+ set idx to ""
87+ end try
88+ set prefix to ""
89+ repeat indent times
90+ set prefix to prefix & " "
91+ end repeat
92+ log prefix & r & " | " & n & " | index:" & idx
93+ try
94+ set children to UI elements of el
95+ repeat with c in children
96+ my dumpElements(c, indent + 1)
97+ end repeat
98+ end try
99+ end dumpElements` ;
100+ }
49101
50102 return `-- Startup delay to reduce chance of "Application isn't running (-600)" errors
51103delay 1
@@ -66,7 +118,7 @@ set command to "
66118 tell its application process \\"Control ${ center } \\"
67119 tell its window 1
68120 -- Check if Do Not Disturb already enabled
69- set doNotDisturbCheckbox to ${ checkboxPosition }
121+ set doNotDisturbCheckbox to checkbox 2 of group 1
70122 set doNotDisturbCheckboxStatus to value of doNotDisturbCheckbox as boolean
71123
72124 tell doNotDisturbCheckbox
0 commit comments