I'd like to make F5 be equivalent to clicking on the mail icon in the taskbar, and F6 equivalent to clicking minimise on the mail app main window (or the 'hide' action). Is there a way to achieve this?
I'm following the method here.
Below is my script which almost works. The problem is I'm clicking a menu item the name of which is not constant.
on run {input, parameters}
tell application "System Events"
tell process "Mail"
set frontmost to true
-- "Inbox (8 Messages)" will only work when 8 messages!:
click menu item "Inbox (8 Messages)" of menu "Window" of menu bar 1
end tell
end tell
return input
end run