Script to tell if "Stickies" is open?

I need a script to look and see if “Stickies” is running. If it finds it running, then it quits Stickies. If it does not find it running then the script does nothing.
I have tried a couple of scripts, but I cant get them to work right. They all end up launching Stickies and then quiting Stickies. I just want it to check and see if Stickies is running and then quit it, not launch it first.
Any help would be GREATLY appreciated.
Larry

: I need a script to look and see if “Stickies” is
: running. If it finds it running, then it quits Stickies. If it
: does not find it running then the script does nothing.
: I have tried a couple of scripts, but I cant get them to work
: right. They all end up launching Stickies and then quiting
: Stickies. I just want it to check and see if Stickies is
: running and then quit it, not launch it first.
This might work. It works for me using OS 9.1 and AppleScript 1.6.
– Begin Code –
tell application “Finder”
try
process “Stickies”
tell application “Stickies” to quit
end try
end tell
– End Code –
Later,
Rob J

: This might work. It works for me using OS 9.1 and AppleScript
: 1.6.

: – Begin Code –

: tell application “Finder”
: try
: process “Stickies”
: tell application “Stickies” to quit
: end try
: end tell

I’d be inclined to keep the ‘quit’ command outside the “Finder” tell block, in case the Finder itself quits:

 try
    tell application "Finder" to get process "Stickies"
    tell application "Stickies" to quit
  end try

There’s also a more conventional approach, which is slightly faster when Stickies isn’t actually running:

tell application "Finder" to get (process "Stickies" exists)
  if the result is true then tell application "Stickies" to quit

NG

: I’d be inclined to keep the ‘quit’ command outside the
: “Finder” tell block, in case the Finder itself
: quits:
: try
: tell application “Finder” to get process “Stickies”
: tell application “Stickies” to quit
: end try

Good advice which I usually follow it, but I didn’t run into any
problems during testing. :slight_smile:

: There’s also a more conventional approach, which is slightly
: faster when Stickies isn’t actually running:
: tell application “Finder” to get (process “Stickies” exists)
: if the result is true then tell application “Stickies” to quit
That works too and I like it!

– Rob