Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Aouttier

macrumors member
Original poster
Mar 3, 2016
42
0
Belgium
I have a script which makes a mail with Cocoa and I want to change the sender of the mail, before sending it. I have multiple account, and the CoCoa takes always the active account.

Now I have a script using the "System Events", but I'm not very happy with it, because it isn't users proof. If a user presses on a key when the script is running, everything runs haywire...

My script so far is:
Code:
    tell application "System Events"
        tell process "Mail"
            click pop up button 1 of window 1
            delay 0.5
            click menu item 9 of menu 1 of pop up button 1 of window 1
        end tell
    end tell

What can I do to improve this?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.