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 > AppleScript - Quitting a Script Application that has an idle Handler

AppleScript - Quitting a Script Application that has an idle Handler
Thread Tools
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Mar 2, 2004, 09:13 AM
 
Hi,

I've got a pretty simple script: here that uses an idle handler to check the status of the network connection.

I'd like to tweak it so that once the network is "good" again the applescript app automatically quits.

So far I have got this:

Code:
on idle try set curlScript to "curl www.apple.com" -- Uncomment the following line if you use a proxy server. -- set curlScript to "curl --proxy address_of_your_proxy_server:port www.apple.com" do shell script curlScript tell application "iTunes" set oldVolume to sound volume set sound volume to (sound volume * 0.25) delay 1 say "Your Network Connection is now available" delay 1 set sound volume to oldVolume display dialog "Network Connection now available." end tell quit on error -- say "Network still down." end try return 120 end idle
Which sort of works - the applet will quit - but only once it has become the foremost app.

Does anyone know if this is how it's supposed to happen? Can I get it to quit in the background? I suppose I could get it to send an applescript to itself - telling it to quit - but that would require hard-coding the name of the applet into the script (not ideal.)
     
Mac Elite
Join Date: Feb 2000
Location: Nashua NH, USA
Status: Offline
Reply With Quote
Mar 2, 2004, 01:45 PM
 
Have you tried putting in a activate call in just before the quit. That should bring it to the front.
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Mar 2, 2004, 04:40 PM
 
Hmm - good point can't believe I forgot Activate!.

Alas same result - the app will only quit when there has been a click somewhere in the app (dock icon, menu bar)

Hmmm...
     
Mac Elite
Join Date: Feb 2000
Location: Nashua NH, USA
Status: Offline
Reply With Quote
Mar 3, 2004, 10:45 AM
 
try

end tell
quit
return 0

on error
....
     
Professional Poster
Join Date: Oct 2001
Location: London
Status: Offline
Reply With Quote
Mar 3, 2004, 03:12 PM
 
No difference - but don't worry - I've just realised that you don't have to click in the applet - keyboard activity / or a mouse click in any app will work.

It's a bit odd - that it waits for input before quitting - but it does quit - so the worst thing that can happen is for there to be a delay before quitting - but that only happens if there's no-one using the computer.
     
   
Thread Tools
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 08:59 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2