Keyboard Shortcuts for Notification Center

@AdamBetts asked:

In Yosemite is there no way to set shortcut/mouse button for Today/Notification separately? Seems odd to have no option for that.

Turns out there’s no “proper” way to do this. So, we resort to Apple’s recently revamped Scripting Tools to kludge together a solution that just clicks the UI elements.

With the help of the trusty “Accessibility Inspector.app”, we can work out the following AppleScript methods:

on displayNotificationCenterToday()
	tell application "System Events"
		click menu bar item "Notification Center" of menu bar 2 of process "SystemUIServer"
		click radio button "Today" of radio group 1 of window "NotificationTableWindow" of process "NotificationCenter"
	end tell
end displayNotificationCenterToday
 
on displayNotificationCenterNotifications()
	tell application "System Events"
		click menu bar item "Notification Center" of menu bar 2 of process "SystemUIServer"
		click radio button "Notifications" of radio group 1 of window "NotificationTableWindow" of process "NotificationCenter"
	end tell
end displayNotificationCenterNotifications
 
-- this plus Accessibility Inspector is how I figured out what to click
--tell application "System Events"
--	get properties of every menu bar item of every menu bar of process "SystemUIServer"
-- get properties of menu bar 2 of process "SystemUIServer"
--	click menu bar item "Notification Center" of menu bar 2 of process "SystemUIServer"
--	click radio button "Today" of radio group 1 of window "NotificationTableWindow" of process "NotificationCenter"
--end tell
 
--displayNotificationCenterNotifications()
--displayNotificationCenterToday()

To call these methods from the keyboard, we hook into OSX’s system-wide Services by creating a custom Service in Automator that takes no input from all applications. We can then assign a keyboard shortcut in System Preferences > Keyboard > Shortcuts > Services. The result:

Notification Center Pane Shortcuts

Here’s a package with the two services you need: displayNotificationCenterPanels.zip