Droplet Launch, Re-launch

(Rick Pepper) #1

Okay Shane, I concede. Lay on me your ASObjC solution (please) to; when I drag and drop files onto a couple different AS droplets that prompt the user for input after the droplet launches (and that prompt is not within a loop ~ it should only occur once), the droplets will randomly re-prompt the user as if files were dropped on the droplet a second time (and all of the files weren’t processed the first time around either).

(Shane Stanley) #2

It’s pretty ugly, but it does the job:

use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use scripting additions
property filesToOpen : {}

on open fileList
	set my filesToOpen to my filesToOpen & fileList
	-- cancel any pending performSelector: requests
	current application's NSObject's cancelPreviousPerformRequestsWithTarget:me
	-- handle files after a short delay in case further events are received
	tell me to performSelector:"doOpen" withObject:(missing value) afterDelay:0.5
end open

on doOpen()
	copy my filesToOpen to fileList
	set my filesToOpen to {} -- reset for next time
	repeat with aFile in fileList
		-- do your stuff
	end repeat
	tell me to quit
end doOpen

on quit
	continue quit
end quit

It needs to be saved stay-open.