• 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: Help with droplet
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with droplet


  • Subject: Re: Help with droplet
  • From: kai <email@hidden>
  • Date: Wed, 4 May 2005 20:31:39 +0100


On Wednesday, May 4, 2005, at 08:02 am, Jon Pugh wrote:

At 2:42 AM -0400 5/4/05, Emmett Gray wrote:
The ASLG is not talking about force quitting. It is talking about quitting with the shift key down, which bypasses the script application's "on quit" handler. In this case, properties are still saved.

Is there a way to trap this behavior?

Not that I know of.

Can you actually get 'quit with shift key-down' (for want of a better term) to work in OS X? (It worked for me in OS 9 but no longer does in OS X - unless the capability has been restored in more recent versions).


Anyway, even if you can't invoke it, I'd understand your reservations about it's possible restoration in the future - so... what to do?

I think I'd be tempted to base the 'first run' test on when the droplet was last saved. That way, even if a 'quit with shift key-down' is induced, the fact that the application file has been saved recently will be noted. This means changing a few things, of course:

[1] delete the boolean 'firstRun' property in favour of a date-based one called, say, 'lastMod'

[2] delete the 'set firstRun to false' statement in the 'doFirstRun' handler

[3] replace [2] above with a 'set jobQueue to {}' statement (to make sure jobQueue's value is also reset)

[4] replace the 'if firstRun then' statement in the 'open' handler with statements to compare modification dates

	[5] lose the 'quit' handler, since it's really no longer required


To help you make better sense of these suggestions, I've modified the script that I originally posted - so that it now looks like this:


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

property lastMod : (current date) - 1
property jobQueue : {}
property idleTime : 10 (* modify as required *)

to processJobQueue()
	repeat until (count jobQueue) is 0
		set currItem to jobQueue's item 1

		-------------------------------
		(* do something with currItem here *)
		-------------------------------

		set jobQueue to rest of jobQueue
	end repeat
end processJobQueue

to doFirstRun(newItems)
	set jobQueue to {}
	activate
	try
		display dialog "Process the dropped item(s)?" with icon 1
		set jobQueue to jobQueue & newItems
		processJobQueue()
	on error number -128 (* user cancelled *)
		quit
	end try
end doFirstRun

on open newItems
	set currMod to (info for (path to me))'s modification date
	if currMod is lastMod then
		set jobQueue to jobQueue & newItems
	else
		set lastMod to currMod
		doFirstRun(newItems)
	end if
end open

on run
	display dialog ¬
		"Drag any item(s) to be processed onto my icon." buttons ¬
		{"OK"} default button 1 with icon 0
	quit
end run

on idle
	if (count jobQueue) > 0 then processJobQueue()
	activate
	set nextAction to (display dialog ¬
		"Quit now?" buttons {"Wait", "Quit"} ¬
		default button 2 with icon 1)'s button returned
	if nextAction is "Quit" then
		quit
		1
	else
		idleTime
	end if
end idle

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

---
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


  • Follow-Ups:
    • Re: Help with droplet
      • From: Jon Pugh <email@hidden>
References: 
 >Re: Help with droplet (From: Jon Pugh <email@hidden>)

  • Prev by Date: Re: Nice Automator article on O'Reilly
  • Next by Date: Re: What is the best way to get the name (without the extension) of a file?
  • Previous by thread: Re: Help with droplet
  • Next by thread: Re: Help with droplet
  • Index(es):
    • Date
    • Thread