• 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: getting a stay open script to do something on system wake up
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting a stay open script to do something on system wake up


  • Subject: Re: getting a stay open script to do something on system wake up
  • From: kai <email@hidden>
  • Date: Tue, 3 May 2005 00:18:29 +0100


On Sunday, May 1, 2005, at 06:44 am, Donald Hall wrote:

I have a stay open script application that I want to execute a certain handler when the computer wakes up. I don't think we have access to pmgtwake any more like we did in OS 9. Here's what I'd like to have in my stay open script:

on computerWakeHandler
-- do stuff
end computerWakeHandler

I've done some web searching but haven't come up with anything for OS X. Does anyone know of a way to do this? Has someone written an osax to get at the power management APIs?

I have a feeling that this has come up before, Don - but I don't recall having seen a solution. It certainly would be handy to have access to such a feature in OS X.


The only workaround that I can come up with at the moment is to mess with date/time stamps. This means that a script won't react immediately following a wake up - although it could be made to react differently, once its normal idle period has elapsed. I don't imagine this is really what you're looking for, but FWIW:

-----------------

property idleTime : 10 (* modify as required *)
property minDelay : 1 (* allow for external activity, etc. *)
property maxDelay : idleTime + minDelay

global dueDate

on regularStartupStuff()
	delay 1 (* simulate some processing *)
end regularStartupStuff

on regularIdleStuff()
	delay 2 (* simulate more processing *)
end regularIdleStuff

on wakeup()
	activate
	beep
	display dialog "Who woke me up?" buttons ¬
		{"Me"} default button 1
	(* trap for any errors, cancel buttons, etc. *)
	set dueDate to (current date) + minDelay
end wakeup

on idle
	if (current date) > dueDate then wakeup()
	regularIdleStuff()
	set dueDate to (current date) + maxDelay
	idleTime
end idle

on run
	regularStartupStuff()
	set dueDate to (current date) + minDelay
end run

-----------------

---
kai

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Prev by Date: Re: Dealing with Japanese filenames??
  • Next by Date: Re: Tiger: Keychain Scripting works? Can't get password...
  • Previous by thread: Re: Dealing with Japanese filenames??
  • Next by thread: Broken mail script
  • Index(es):
    • Date
    • Thread