how to launch an application in Mac OS X?

Ian Summerfield iansummerfield at btconnect.com
Mon Apr 8 01:24:01 EDT 2002


To launch an application in OS X,  first find out if it's already running,
if it is you probably only want to bring it to the front,  if it isn't then
you can launch it.  This is the code I use,  it's lengthy but robust.

Call StarProg with the name of the program as the first parameter "Quicktime
Player" and the complete path to the program as the second parameter, I
think you'll need:

  /Diskname/Applications/QuickTime Player.app/Contents/MacOS/Quicktime
Player

Create a custom property in the stack called "AppleScript1" and set its
contents to:

tell application "Finder"
return name of every process
end tell

Put on a card script:

global processlist


on getprocesses
  do the applescript1 of this stack as AppleScript
  put the result into processlist
end getprocesses

function startProg theName,thePath
  getprocesses
  if quote&theName&quote is in processlist then
    do "tell application " & quote & theName & quote & " to activate" as
applescript
    return "Active"
    exit startProg -- already running
  end if
  if there is not a file thePath then
    return "ERROR: No such application."
    exit startProg
  end if
  KILL quit process thePath -- clears the openProcesses, otherwise RR will
  -- return "process already running" on the launch
  launch thePath
  put the result into res
  -- check the result for "error -nn"
  Return res
end startProg



On 7/4/02 2:38 pm, "Luke Martin" <lmartin4 at mac.com> scribed:

> I am running Mac OS X 10.1.3. What is the proper way to launch an
> application in Mac OS X (i.e. QuickTime Player)?
> 
> Cheers
> Luke
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution





More information about the use-livecode mailing list