Skip to content

Instantly share code, notes, and snippets.

@gja
Last active December 14, 2015 10:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gja/5070457 to your computer and use it in GitHub Desktop.
Save gja/5070457 to your computer and use it in GitHub Desktop.
Mail.app: Send file in 5 seconds. This script minimizes the current message, waits for five seconds, and then opens the message and sends the mail out. If you unminimize the app, then the mail is also cancelled.
on run {input, parameters}
tell application "Mail"
set theWindow to front window
set miniaturized of theWindow to true
end tell
set question to display dialog "Sending Mail" buttons {"Send Now", "Stop"} default button 2 giving up after 12
set answer to button returned of question
tell application "System Events"
set currentApplication to name of the first process whose frontmost is true
end tell
tell application "Mail"
activate
set stillMinimized to miniaturized of theWindow
set notCancelled to answer is not equal to "Stop"
activate theWindow
set miniaturized of theWindow to false
end tell
if stillMinimized and notCancelled then
tell application "System Events"
tell process "Mail"
keystroke "d" using {command down, shift down}
end tell
end tell
end if
tell application currentApplication to activate
end run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment