How can I use Automator to change the modem settings for sending emails on a Mac?

Paul March 26, 2011

I need to change my modem settings every time I send an email and back again afterwards. How can I use Automator to select the appropriate buttons on the modem browser pages?

  1. Tina
    March 27, 2011 at 6:37 pm


    let us know whether the answers provided above helped you to solve your problem. Thank you!

  2. Anonymous
    March 27, 2011 at 12:12 pm
  3. Mike
    March 26, 2011 at 9:10 pm

    Automator can only run existing Actions and Scripts.

    What you are trying to do needs to be done in AppleScript.
    There are tons of ways to select and click things but sometimes it is very confusing to find the right way and identifier for things.

    There are 3 ways to interact with the GUI - buy numbers, by name, combination:

    select menu item 1 of menu 4
    click button 2 on tab 3
    select item "blabla" of menu "Views"
    select item 1 of menu "Settings"

    They all will translate into valid AppleScript

    However this can get very unpractical. Just to select AirPort the Script would look something like that:

    tell application "System Preferences"
    set current pane to pane ""
    tell application "System Events" to tell window 1 of process "System Preferences"
    select (row 1 of table 1 of scroll area 1 whose value of static text 1 contains "AirPort")
    end tell
    end tell

    As you can see this can get very ugly!


    If you have like 2 different settings I suggest to create Network Locations within Network Preferences. For example create "Modem Settings 1" and "Modem Settings 2" and make all the necessary changes in there.

    Again, selecting the Location using AppleScript will be very challenging. Luckily this is something that can be done using Automator and Shell-Scripting.

    Create one Automator Action for each of the Locations. The Shell command to change location is so much easier than using the GUI:

    scselect "Modem Settings 1"
    scselect "Modem Settings 2"

    The last step would be to create Rules within Apple Mail Preferences which will Run the appropriate Automator-Shell-Script.

    On a general note:
    I always suggest to look into Shell-Scripting because pretty much everything you do within the GUI will run some Terminal command in the background.
    Of course there are exceptions where GUI Scripting and AppleScript is necessary.

    • Mike
      March 26, 2011 at 9:17 pm

      I just realized that Apple Mail Rules are not able to act on sending Emails so ignore my The last step... command... Automator does have the Action "send E-Mails" so you might be able to include this with the Shell-Script.

      For the whole Automator-Script could look something like that:

      Automator-Action > Run Shell-Script
      scselect "Modem Settings 2"

      Automator-Action > Send E-Mails

      Automator-Action > Run Shell-Script
      scselect "Modem Settings 1"