Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save antoniocapelo/59140321c1433283a402e3848a3df907 to your computer and use it in GitHub Desktop.

Select an option

Save antoniocapelo/59140321c1433283a402e3848a3df907 to your computer and use it in GitHub Desktop.
AppleScript to open/click macOS notification banners via keyboard shortcut (Sequoia 15.x) — use with BetterTouchTool, Keyboard Maestro, etc.
-- Open/click the most recent macOS notification banner without using the mouse.
-- Tested on macOS Sequoia 15.6 (Apple M4).
--
-- Usage:
-- 1. BetterTouchTool → Keyboard Shortcuts → Add shortcut → Run Apple Script (async in background)
-- 2. Paste this script and assign your preferred hotkey (e.g. Ctrl+Shift+N)
-- 3. Press the hotkey while a notification banner is visible on screen
--
-- Requirements:
-- • Your automation app (BetterTouchTool, Script Editor, etc.) must be enabled in:
-- System Settings → Privacy & Security → Accessibility
--
-- How it works:
-- The notification banner in Sequoia is an AXGroup with subrole AXNotificationCenterBanner
-- inside: window 1 → group 1 → group 1 → scroll area 1 → first group
-- It exposes an AXPress action ("Show Details") which is equivalent to clicking the banner.
tell application "System Events"
tell process "NotificationCenter"
try
perform action "AXPress" of first group of scroll area 1 of group 1 of group 1 of window 1
end try
end tell
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment