1

I have been trying to write an AppleScript that would open the mail app register a save as key event (Shift+Command+S) wait 1.5 seconds, do a return key event ("Enter") and then wait another 1 second and then register a down arrow key event.

activate application "Mail"
repeat 2310 times
    tell application "System Events" to keystroke "s" using {shift down,command down}
    delay 1.5
    tell application "System Events" to keystroke "return"
    delay 1
    tell application "System Events" to keystroke "DownArrow"
end repeat
  • 1
    Can you add the code that you have written already? – grg May 30 '15 at 19:00
  • @grgarside Added – Sawyer Powell May 30 '15 at 19:12
  • Since Mail.app can be scripted, I don't think you should use UI scripting but script Mail.app directly - to get an idea, open Mail.app with Script-Editor. + Script-Editor has a template for a "Mail Rule Action" (see menu File) and this is maybe even a way to go… (in Mail, we can apply a rule to a selection. Rules can be created in Mail's Preferences and they can run scripts). google.com/search?q=Mail.app+saving+emails+with+applescript – user128544 May 31 '15 at 18:22
1
tell application "System Events" to repeat 2310 times
    tell application process "Mail" to set frontmost to true
    keystroke "s" using {shift down, command down}
    delay 1.5
    keystroke return
    delay 1
    key code 125
end repeat

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .