Professional Web Applications Themes

AppleScript question - Mac Applications & Software

In AppleScript, how can you write a script to check whether or not a given application is running? -- ³There are no mistakes in love.² - Patty Smyth...

  1. #1

    Default AppleScript question

    In AppleScript, how can you write a script to check whether or not a
    given application is running?

    --
    ³There are no mistakes in love.²
    - Patty Smyth
    Keeper Guest

  2. #2

    Default Re: AppleScript question

    In article <west.cox.net>, Michelle
    Steiner <org> wrote:
     
    >
    > tell application "System Events"
    > "mail" is in name of processes
    > --replace mail with name of the app you are testing for
    > end tell[/ref]

    How do you work this into an if-then statement? (Meaning, do one thing
    if an application is running, do a different thing if it's not running)

    --
    ³There are no mistakes in love.²
    - Patty Smyth
    Keeper Guest

  3. #3

    Default Re: AppleScript question

    In article <west.cox.net>, Michelle
    Steiner <org> wrote:
     
    >
    > tell application "System Events"
    > "mail" is in name of processes
    > --replace mail with name of the app you are testing for
    > end tell[/ref]

    Oops, never mind. I tried that, and it didn't work. It says that the
    variable "processes" is not defined.

    --
    ³There are no mistakes in love.²
    - Patty Smyth
    Keeper Guest

  4. #4

    Default Re: AppleScript question

    In article <130820032329326132%invalid>,
    Keeper of the Purple Twilight <invalid> wrote:
     
    > >
    > > tell application "System Events"
    > > "mail" is in name of processes
    > > --replace mail with name of the app you are testing for
    > > end tell[/ref]
    >
    > How do you work this into an if-then statement? (Meaning, do one thing
    > if an application is running, do a different thing if it's not running)[/ref]

    tell application "System Events"
    if "mail" is in name of processes then
    -- do something
    else
    -- do something else
    end if
    end tell

    Regards,

    Don

    --
    Donald S. Hall, Ph.D.
    Apps & More Software Design, Inc.
    www.appsandmore.com
    don at appsandmore dot com
    "Schedule your AppleScripts with Script Timer"
    Donald Guest

  5. #5

    Default Re: AppleScript question

    In article <130820032331143093%invalid>,
    Keeper of the Purple Twilight <invalid> wrote:
     
    >
    > Oops, never mind. I tried that, and it didn't work. It says that the
    > variable "processes" is not defined.[/ref]

    It works for me; I tested it before posting it. Which version of the OS
    and of AS are you using?

    --
    Never play strip tarot.
    Michelle Guest

  6. #6

    Default Re: AppleScript question

    In article <130820032329326132%invalid>,
    Keeper of the Purple Twilight <invalid> wrote:
     
    >
    > How do you work this into an if-then statement? (Meaning, do one thing
    > if an application is running, do a different thing if it's not running)[/ref]

    tell application "System Events"
    if "mail" is in name of processes then
    --do something
    else
    --do something else
    end if
    end tell

    --
    Never play strip tarot.
    Michelle Guest

  7. #7

    Default Re: AppleScript question

    In article <west.cox.net>, Michelle
    Steiner <org> wrote:
     
    > >
    > > Oops, never mind. I tried that, and it didn't work. It says that the
    > > variable "processes" is not defined.[/ref]
    >
    > It works for me; I tested it before posting it. Which version of the OS
    > and of AS are you using?[/ref]

    OS X 10.2.6. AppleScript...let's see...Script Editor says 1.9.

    --
    "Boom. Boom boom boom. Boom boom. BOOM. Have a nice day."
    - Susan Ivanova, B5
    Keeper Guest

  8. #8

    Default Re: AppleScript question

    In article <140820030249229758%invalid>,
    Keeper of the Purple Twilight <invalid> wrote:
     

    [...]
     
    >
    > [...] Unfortunately, it still doesn't work right. It does the first "if"
    > part, but then it goes right to "else" and tries to execute that too.[/ref]

    Something's wrong with your OS or AS install. (It might be worth trying
    the same thing under a different user).

    You could try replacing the phrase "System Events" with "Finder". I
    would be surprised if it'd make a difference, but it won't hurt to try.

    [...]
     

    Why paraphrase? This way noone will be able to spot typos. (Though the
    only thing wrong in what you posted that I can spot is the use of
    'single' quotes.)


    [Btw, there's a newsgroup dedicated to AS:
    <news:alt.comp.lang.applescript>]

    --
    Free and shareware at <http://www.euronet.nl/~tekelenb/software/>
    Sander Guest

Similar Threads

  1. Illustrator CS & applescript
    By Tobias_Vollprecht@adobeforums.com in forum Adobe Illustrator Macintosh
    Replies: 2
    Last Post: May 15th, 03:47 PM
  2. AppleScript
    By jcc31 webforumsuser@macromedia.com in forum Macromedia Freehand
    Replies: 3
    Last Post: January 22nd, 11:03 PM
  3. Newbie Applescript question
    By Alan in forum Mac Applications & Software
    Replies: 1
    Last Post: August 19th, 05:17 PM
  4. Simple AppleScript question
    By Julien Salort in forum Mac Programming
    Replies: 2
    Last Post: August 14th, 05:54 PM
  5. applescript?
    By Barbara Brundage in forum Adobe Photoshop Elements
    Replies: 12
    Last Post: August 9th, 01:47 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139