• 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: AppleScript Droplet seems to receive strange file list
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript Droplet seems to receive strange file list


  • Subject: Re: AppleScript Droplet seems to receive strange file list
  • From: Shane Stanley <email@hidden>
  • Date: Sat, 18 Feb 2017 13:58:54 +1100

On 18 Feb 2017, at 12:07 pm, Shane Stanley <email@hidden> wrote:

The problem here is that multiple events are being sent, with the files split between them.

This is what Yvan was seeing, and it can be dealt with if necessary, at the cost of a slight delay (and extra complexity, obviously). Save this as a stay-open applet:

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


set aRes to length of fileList
display dialog aRes as string


repeat with i in fileList
set j to POSIX path of i
display dialog j
end repeat


tell me to quit
end doOpen

on quit
continue quit
end quit

That should coalesce multiple open events.

-- 
Shane Stanley <email@hidden>
<www.macosxautomation.com/applescript/apps/>, <latenightsw.com>


 _______________________________________________
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: 
 >AppleScript Droplet seems to receive strange file list (From: Takaaki Naganoya <email@hidden>)
 >Re: AppleScript Droplet seems to receive strange file list (From: Yvan KOENIG <email@hidden>)
 >Re: AppleScript Droplet seems to receive strange file list (From: Shane Stanley <email@hidden>)
 >Re: AppleScript Droplet seems to receive strange file list (From: Takaaki Naganoya <email@hidden>)
 >Re: AppleScript Droplet seems to receive strange file list (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: AppleScript Droplet seems to receive strange file list
  • Next by Date: Re: Need Reference for "tell application" forms
  • Previous by thread: Re: AppleScript Droplet seems to receive strange file list
  • Next by thread: Re: AppleScript Droplet seems to receive strange file list
  • Index(es):
    • Date
    • Thread