Skip to content

Instantly share code, notes, and snippets.

@SKaplanOfficial
Created December 16, 2025 12:49
Show Gist options
  • Select an option

  • Save SKaplanOfficial/12d9c68ed0a0e4fd3d4b83a840618fc6 to your computer and use it in GitHub Desktop.

Select an option

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.
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