Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > simple applescript question

simple applescript question
Thread Tools
BGK
Forum Regular
Join Date: Oct 2000
Location: Roanoke, VA USA
Status: Offline
Reply With Quote
Dec 6, 2000, 12:26 PM
 
I'm super new to this. i want to write a script to close all applications that are running. I thought it would be:

tell application "finder"
close all applications
end tell

but this didn't work. it didn't recognize the word applications on the second line.

what's wrong with my code here?

if this question is out of place, please redirect me to the appropriate forum. thanks.
I want the ability to sleep in the snow, if I have to. I want the ability to want to.
     
Cipher13
Registered User
Join Date: Apr 2000
Status: Offline
Reply With Quote
Dec 6, 2000, 06:47 PM
 
I'm not on my Mac at the moment, but try SOMETHING like this:

on run
put openApps into apps
quit apps
end run

I dunno... thats off the top my my aching head and it will not work, but its something of that sort.

Cipher13
     
tonymac
Dedicated MacNNer
Join Date: May 2000
Location: Chattanooga, TN
Status: Offline
Reply With Quote
Dec 6, 2000, 07:40 PM
 
tell application "Finder"
set theProcs to every process whose (file type is "APPL")
repeat with theApp in theProcs
set appName to name of theApp
if appName is not "Finder" then
tell application appName
quit
end tell
end if
end repeat
end tell

[edit: This should be in the Programming forum.]

[This message has been edited by tonymac (edited 12-06-2000).]
     
BGK  (op)
Forum Regular
Join Date: Oct 2000
Location: Roanoke, VA USA
Status: Offline
Reply With Quote
Dec 6, 2000, 07:41 PM
 
nope that didn't work. and I'm still trying to figure it out. wish me luck. anyone else have any ideas? I need to find an Apple Script message board.
I want the ability to sleep in the snow, if I have to. I want the ability to want to.
     
BGK  (op)
Forum Regular
Join Date: Oct 2000
Location: Roanoke, VA USA
Status: Offline
Reply With Quote
Dec 6, 2000, 11:17 PM
 
sorry, this "nope" was to cipher's response. must have posted almost at the same time tonymac was posting and I got second. however, the nope goes out to tony too. I tried yours and it just managed on closing the actual finder! which I didn't think was even possible. when I closed all the other apps (manually), the finder, the startup disk, and desktop icons, all appeared again. hmmmm.... this is interesting.

note: can the administrator shift this thread on over to the programming forum?
I want the ability to sleep in the snow, if I have to. I want the ability to want to.
     
tonymac
Dedicated MacNNer
Join Date: May 2000
Location: Chattanooga, TN
Status: Offline
Reply With Quote
Dec 6, 2000, 11:37 PM
 
Apologies. I took that from another, more complex script that I wrote, and adapted it. The correct script is:
tell application "Finder"
set theProcs to every process whose (file type is "APPL")
end tell
repeat with theApp in theProcs
set appName to name of theApp
if appName is not "Finder" then
tell application appName
quit
end tell
end if
end repeat

The problem was that the quit was nested in the tell "Finder" block. This should work. If you're saving this as an application, you may have to substitute the name of your applet for "Finder" in the if then statement.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 04:26 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,