Friday, August 14, 2020

#1 2020-01-16 05:51:17 am

timbaldwin
Member
Registered: 2006-08-14
Posts: 75

Folder Action to launch an app's "on open" handler

Hi

I am trying to work out to write a folder action script that launches a separate AppleScript application that will process the files/folders dropped in the hot folder as if the item was dragged and dropped on the application icon itself.

In other words I'm trying to write a folder action that runs the app's "on open" handler and then processes the dropped files one by one.

P.S.   I also have an "on run" handler in the app which runs when the application when clicked on by the user (this handler is used to change setting etc).

I have the application done and it works fine when items are dropped on it.  What I can't work out is how to write the folder action script so that I can have a hot folder that does the same.

Hope this is clear.

Any help would be appreciated.

Thanks

Tim

Last edited by timbaldwin (2020-01-16 05:52:25 am)


Tim

Offline

 

#2 2020-01-16 08:45:38 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4568

Re: Folder Action to launch an app's "on open" handler

You may try something like :

Applescript:

on adding folder items to this_folder after receiving these_items
   set targetApp to ((path to desktop as text) & "droplet.app:") as «class furl»
   tell application "Finder"
       open these_items using targetApp
   end tell
end adding folder items to

I tested it with the droplet "droplet.app" whose code is :

Applescript:

#=====

on open sel # sel contient une liste d'alias des éléments
   # qu'on a déposés sur l'icône du script (la sélection)
   
   repeat with aFile in sel
       set itsName to name of (get info for aFile)
       display notification itsName sound name "Ping"
       delay 2
   end repeat
end open #

#=====

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 16 janvier 2020  15:45:25

Offline

 

#3 2020-01-21 06:56:15 am

timbaldwin
Member
Registered: 2006-08-14
Posts: 75

Re: Folder Action to launch an app's "on open" handler

Thanks Yvan

That should do the trick!  smile


Tim

Offline

 

#4 2020-01-23 09:02:31 am

Joy
Member
From:: South Tirol
Registered: 2008-07-04
Posts: 643
Website

Re: Folder Action to launch an app's "on open" handler

Hi timbaldwin

I think it's a bit unfair to "request" something final in a forum unless you put a bit of effort yourself and share your wisdom with the community

The reason is simple, we gather here to learn and help each other, happy to be part of the whole.

You're welcome to contribute with your own ideas to share an unique experience with us all, so everybody can enjoy to be online here.

Offline

 

#5 2020-02-03 08:06:07 am

timbaldwin
Member
Registered: 2006-08-14
Posts: 75

Re: Folder Action to launch an app's "on open" handler

Joy wrote:

Hi timbaldwin

I think it's a bit unfair to "request" something final in a forum unless you put a bit of effort yourself and share your wisdom with the community

The reason is simple, we gather here to learn and help each other, happy to be part of the whole.

You're welcome to contribute with your own ideas to share an unique experience with us all, so everybody can enjoy to be online here.




Hi Joy

I am not sure what you mean..  My request was not for anything final.  Please read the post and you will see that I had a problem with one aspect of a calling a script application that I had already written.

If you are unable to help please feel free not to help.

I am not sure discouraging people from seeking help is very productive in this type of forum.

Tim


Tim

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)