Last active
December 14, 2015 10:10
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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