Created
December 16, 2025 12:49
-
-
Save SKaplanOfficial/12d9c68ed0a0e4fd3d4b83a840618fc6 to your computer and use it in GitHub Desktop.
AppleScript handler to open an application's Settings window via its "Settings..." menu item.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| on displaySettingsWindow(theApplication) | |
| (* | |
| * Opens the settings window for an application via its "Settings..." menu item. | |
| * Returns a reference to the front window of the corresponding application process. | |
| *) | |
| set appName to missing value | |
| if class of theApplication is text then | |
| set appName to theApplication | |
| else if class of theApplication is application then | |
| set appName to name of theApplication | |
| else | |
| error "Expected app name string or application object specifier, got " & (class of theApplication as text) & " instead." number -8080 | |
| end if | |
| set appProcess to missing value | |
| tell application "System Events" | |
| try | |
| set appProcess to first application process whose name is appName and background only is false | |
| on error number -1719 | |
| error "Application '" & appName & "' not found." number 8081 | |
| end try | |
| click menu item "Settings…" of menu appName of menu bar 1 of appProcess | |
| end tell | |
| tell application appName | |
| -- Wait for the window to open. | |
| -- If the window uses some other name, just assume it's open after ~3 seconds. | |
| set loopTimeout to 30 | |
| repeat while name of window 1 is not appName & " Settings" and loopTimeout > 0 | |
| set loopTimeout to loopTimeout - 1 | |
| delay 0.1 | |
| end repeat | |
| end tell | |
| tell application "System Events" | |
| return a reference to window 1 of appProcess | |
| end tell | |
| end displaySettingsWindow |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment