• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Application Bundle won't quit at Shutdown [Solved]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Application Bundle won't quit at Shutdown [Solved]


  • Subject: Re: Application Bundle won't quit at Shutdown [Solved]
  • From: email@hidden
  • Date: Tue, 15 Dec 2009 13:12:48 -0800

I finally got it to work.  Apparently, my last problem was caused by me placing the on idle handler lines in the wrong spot.  =:\

Thank you to everyone who responded - Ed, Has, Yvan, Axel, Paul, and Roy.  I truly appreciate your help.  I took everyone's ideas and was able to get this script to work the way that it should, plus I was able to eliminate the "kill" command in the 'on quit' handler.

In case anyone else is interested in using this script to check multiple Mail accounts at different intervals, I've enclosed it here.  I will also post this online for the benefit of others, so if anyone has any ideas on how to clean this up even more, I'd appreciate hearing them.

Thanks again,
Ted

-----------

(* 
PURPOSE:
   Check individual Apple Mail accounts at different intervals that you determine.


INSTRUCTIONS:
   Set Mail's preferences to "Check for new mail: Manually".
   Save this script as an Application Bundle and select the Stay Open option.
*)

global theMinimumInterval, theAccountList, theMinuteCount, ScriptName

set scriptPath to path to me

-- Get full name of this script.
tell application "Finder"
set scriptNameFull to name of scriptPath
set theExt to name extension of scriptPath
end tell

-- Get the name of this script, minus the extension
if theExt is not "" then
set ScriptName to (text items 1 thru -(2 + (length of theExt)) of scriptNameFull) as string
end if

-- Hide this script's icon in the Dock
tell application "System Events"
tell process ScriptName
keystroke "h" using command down
end tell
end tell

tell application "Mail"
activate
check for new mail
set theMinimumInterval to 0
set theAccountList to ¬
{¬
{account "work" of application "Mail", 15}, ¬
{account "personal" of application "Mail", 40}, ¬
{account "lists" of application "Mail", 90} ¬
                    -- Add as many Mail accounts as you have.
}


set theCount to 0
repeat with eachAccount in theAccountList
set theInterval to item 2 of eachAccount
if theInterval ≠ 0 then
set theCount to theCount + 1
if (theCount > 1) then
set theMinimumInterval to my gcd(theInterval, theMinimumInterval)
else
set theMinimumInterval to (theInterval as integer)
end if
end if
end repeat
if theMinimumInterval = 0 then
display dialog "No accounts will be checked (at least one value needs to be greater than 0)."
return
end if
end tell

set theMinuteCount to 0
on idle
set theMinuteCount to theMinuteCount + theMinimumInterval
repeat with eachAccount in theAccountList
set theAccount to item 1 of eachAccount
set theInterval to item 2 of eachAccount
if theInterval ≠ 0 then
set theMod to theMinuteCount mod theInterval
if (theMod = 0) then
tell application "Mail" to check for new mail for theAccount
end if
end if
end repeat
return (theMinimumInterval * 60)
end idle


on gcd(a, b)
repeat until b = 0
set x to b
set b to a mod b
set a to x
end repeat
return a
end gcd

on quit
continue quit
end quit

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: Application Bundle won't quit at Shutdown (From: has <email@hidden>)
 >Re: Application Bundle won't quit at Shutdown (From: email@hidden)
 >Re: Application Bundle won't quit at Shutdown (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Plug-ins
  • Next by Date: Re: Plug-ins
  • Previous by thread: Re: Application Bundle won't quit at Shutdown
  • Next by thread: Re: Application Bundle won't quit at Shutdown
  • Index(es):
    • Date
    • Thread