• 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: launch an application, and on quit, logout?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: launch an application, and on quit, logout?


  • Subject: Re: launch an application, and on quit, logout?
  • From: "J. Stewart" <email@hidden>
  • Date: Wed, 24 Jun 2009 17:09:25 -0400

On 6/24/09 at 12:38 PM, Mike Stanley <email@hidden> spake thusly:

I am trying to do something that seems like it should be easy, but I
must not be wording my searches correctly, because what I've mostly
come up with is discussions of how to make a script quit apps and
force a logout.

What I'm trying to do is make an applescript that I can place in a
user's login items.  What I'd like that script to do is:

1.  Launch an application in the user's home area
2.  Wait for that application to quit and when it does
3.  Log the user out

Is that possible? If so, does anybody have anything they could share?

--> Cut <-- on run tell application "Mail" to activate end run on idle tell application "System Events" to set foo to (exists process "Mail") if foo then -- Mail is running return 10 -- seconds else -- goodbye ignoring application responses tell application "loginwindow" to «event aevtrlgo» end ignoring end if end idle --> Cut <--

Any line in this script which starts at the left margin has been wrapped.
You may need to manually append such a line to the end of the preceeding line if it's a "hard" wrap.


As Luther did, I used Mail as an example but did things a bit differently.

This script should be saved as a "stay open" application bundle. The big reason is the ability to make an application bundle "background only" and the ability to remove its icon from the Dock. You can check the archives or re-post for info on how those are done.

As written it checks for Mail.app every 10 seconds and if it isn't there, logs the account out. You might want/need to adjust the timing depending on how long it takes for your app to show up as running.

To meet your specs it should be run as a login item.

John
--
Experience should teach us to be most on our guard to protect liberty when the Government's purposes are beneficent. Men born to freedom are naturally alert to repel invasion of their liberty by evil-minded rulers. The greatest dangers to liberty lurk in insidious encroachment by men of zeal, well-meaning but without understanding.  -Justice Louis D. Brandeis, dissenting, Olmstead v. United States
_______________________________________________
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: 
 >launch an application, and on quit, logout? (From: Mike Stanley <email@hidden>)

  • Prev by Date: Re: launch an application, and on quit, logout?
  • Next by Date: Re: Open for access oddity
  • Previous by thread: Re: launch an application, and on quit, logout?
  • Next by thread: Re: launch an application, and on quit, logout?
  • Index(es):
    • Date
    • Thread