Monday, July 23, 2018

#1 2003-06-20 11:39:43 am

mipadi
Member
From:: Pennsylvania, USA
Registered: 2003-06-20
Posts: 7

See if app is running & quit it

I'm trying to see if an application is running, and if it is, then quit it. I tried these two lines of code:

Applescript:

if application "Internet Explorer" is active then
       tell application "Internet Explorer" to quit

but they don't seem to work. How can I properly code this?


Filed under: internet

Offline

 

#2 2003-06-20 11:58:44 am

johnfountain
Member
Registered: 2003-06-06
Posts: 44

Re: See if app is running & quit it

Try this:

Applescript:

if (list processes) contains "Mail" then
   tell application "Mail" to quit
end if

HTH -john


Filed under: mail

Offline

 

#3 2003-06-20 12:06:11 pm

mipadi
Member
From:: Pennsylvania, USA
Registered: 2003-06-20
Posts: 7

Re: See if app is running & quit it

I got an error -- "The variable process is not defined."

Offline

 

#4 2003-06-20 01:07:19 pm

xnetzero
Member
Registered: 2003-06-17
Posts: 4

Re: See if app is running & quit it

==========
set targetApp to "application"

tell application "System Events"
    set processExists to exists process targetApp
end tell

if processExists is true then
    tell application "application"
        quit
    end tell
end if
==========


==========
XnetZERO
==========

¡Vaya Con Macintosh!


Filed under: Application, System

Offline

 

#5 2003-06-20 01:19:58 pm

johnfountain
Member
Registered: 2003-06-06
Posts: 44

Re: See if app is running & quit it

I got an error -- "The variable process is not defined."



Can I ask what version of the System software you are running? The term "process" only recently became supported in osX. Up until 10.2.4 or .5 it was still listed as unimplemented according to the finder dictionary. I ran my version of the script on 10.2.6 it should also work in os 9.

You can try this in versions of osX older than 10.2.6

Applescript:

set psList to do shell script "ps -auxw | grep "Mail""
if psList contains "Mail.app" then tell application "Mail" to quit

-john


Filed under: mail

Offline

 

#6 2003-06-20 01:32:50 pm

mipadi
Member
From:: Pennsylvania, USA
Registered: 2003-06-20
Posts: 7

Re: See if app is running & quit it

I'm using 10.2.6.

Offline

 

#7 2003-06-20 02:16:03 pm

julifos
Administrator
From:: Malasaña, Madrid
Registered: 2002-11-20
Posts: 2014

Re: See if app is running & quit it

Try this:

Applescript:

if (list processes) contains "Mail" then
   tell application "Mail" to quit
end if

HTH -john

Perhaps mipadi put the code out of a Finder "tell block", but this may work:

Applescript:

tell application "Finder" to if (list processes) contains "Mail" then tell application "Mail" to quit

Also, to retrieve a parsed list of name of processes, you can try this:

Applescript:

tell app "Finder" to name of processes


Filed under: mail, Finder

Offline

 

#8 2003-07-02 04:17:02 am

bracken
Member
Registered: 2003-01-13
Posts: 3

Re: See if app is running & quit it

You could do it like this.

Applescript:


do shell script "kill `ps ax | grep Preview.app | grep -v grep | cut -d" " -f2`"

Offline

 

#9 2003-07-02 09:02:36 am

julifos
Administrator
From:: Malasaña, Madrid
Registered: 2002-11-20
Posts: 2014

Re: See if app is running & quit it

Yep! But kill a process is not the same as "quit" it...

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)