How to open 2 programs from the dock with 1-click?

Discussion in 'macOS' started by JonnyBlaze, Oct 30, 2009.

  1. JonnyBlaze macrumors regular

    Joined:
    May 5, 2008
    Location:
    UK
    #1
    Hello,

    as the title suggests, I'm looking for a way to open 2 programs at the same time when I click one from the dock.
    My example is opening Spotify, and I want Airfoil to open at the same time to stream the audio.

    Thanks in advance for any ideas.

    Jon
     
  2. sammich macrumors 601

    sammich

    Joined:
    Sep 26, 2006
    Location:
    Sarcasmville.
    #2
    One way is to use AppleScript. Open up 'AppleScript Editor' in Utilities.

    Put this code in the blank document:
    Code:
    tell application "Spotify" to activate
    tell application "Airfoil" to activate
    Then go to save, select the file format as 'Application'. Only 'Run Only' should be checked. Then put that app in your dock.
     
  3. pit29 macrumors 6502a

    pit29

    Joined:
    May 23, 2006
    Location:
    The Golden State
    #3
    Record it with AppleScript, save the script as application and then put its icon in the dock...


    ---
    edit: only seconds late...
     
  4. stridemat Moderator

    stridemat

    Staff Member

    Joined:
    Apr 2, 2008
    Location:
    UK
    #4
    You could create an application in Automator that will open both programs on a single click. Obviously have the corresponding apps in the correct sections. Once you have saved the application put it on the dock and it should work nicely.
     

    Attached Files:

  5. JonnyBlaze thread starter macrumors regular

    Joined:
    May 5, 2008
    Location:
    UK
    #5
    Thanks very much for the speedy replies...I'll have a go this afternoon. Hope all goes to plan!

    Jon


    Edit:

    Well I shouldn't have doubted that it would be easy, never mind trying this afternoon, it only took a minute!

    I've done it with the script editor, and with automator as well. Not having used either of these before, what the difference between them? It doesn't seem to make much difference which one you use for this example?

    Thanks again though for your help.

    Jon
     
  6. kryptonianjorel macrumors 6502

    Joined:
    Jul 3, 2009
  7. sammich macrumors 601

    sammich

    Joined:
    Sep 26, 2006
    Location:
    Sarcasmville.
    #7
    Automator is essentially a nice package that does all it's work via Applescript. Anything you can write in Applescript you can in Automator and vice versa, although much of the commands are premade, drag and drop and just plain easy.
     
  8. calderone macrumors 68040

    calderone

    Joined:
    Aug 28, 2009
    Location:
    Seattle
    #8
    This is a bit off. You can do a lot of stuff with automator, but it cannot do anything I can write in Applescript.

    Sure basic things like "Launching an Application." Or a folder action. But by no means anything Applescript can do.
     
  9. JonnyBlaze thread starter macrumors regular

    Joined:
    May 5, 2008
    Location:
    UK
    #9
    Hello again,

    after managing to open 2 programs simultaneously, I'm wondering about other uses for scripts/automator.

    The way I use airfoil, is to stream audio from 1 specific program (spotify or VLC usually) rather than all system audio. Now, is it possible to use scripts/automator, to open the two programs simultaneously, and specify that the program opened alongside Airfoil is the one it should stream from?

    This would be useful, as Airfoil by default chooses the last opened program. I imagine this is getting a bit more complex, so a yes/no answer will be fine if explainations will be too lengthy. Maybe someone could point me in the direction of a good guide to scripts/automator also.

    Thanks very much for the help.

    Jon
     
  10. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
  11. sammich macrumors 601

    sammich

    Joined:
    Sep 26, 2006
    Location:
    Sarcasmville.
    #11
    Look up "Run AppleScript" in the Automator Library :D
     
  12. JonnyBlaze thread starter macrumors regular

    Joined:
    May 5, 2008
    Location:
    UK
    #12
    Thanks for everyones suggestions! It really didn't take long to get my head around this, but there were a few key places I found to help me.

    After having read on the Airfoil website about their scripts, and some great guides on this site http://mac.appstorm.net/ I've written the script to open Spotify and Airfoil, and automatically transmit audio from Spotify!

    Thanks again, and in case anyone's interested I've included the script as text below...



    AppleScript to open Spotify and Airfoil, and stream audio from Spotify.

    tell application "Spotify" to activate
    tell application "Airfoil" to activate

    tell application "Airfoil"
    set aSource to make new application source
    set application file of aSource to "/Applications/Spotify.app"
    set current audio source to aSource

    end tell
     

Share This Page