Re: Folder Action the Cocoa Way
Re: Folder Action the Cocoa Way
- Subject: Re: Folder Action the Cocoa Way
- From: John Stiles <email@hidden>
- Date: Sun, 25 Jun 2006 16:05:39 -0700
I will warn you that if the path can have non-ASCII characters in it—and
this can be true even on American systems, if your users have creative
hard drive names—your script won't run. AppleScript in general does an
awful job with Unicode. This has bit me in the past.
You can use file:// URLs and then percent-encode the Unicode (as UTF8).
This has worked for me in some cases. It depends if your script can use
a URL or not. I'm not an AppleScript guru or I'd give more specific
examples :)
Mark Butler wrote:
Thanks Pablo,
You were right NSAppleScript did the trick.
NSAppleScript *folderActionScript;
folderActionScript=[[NSAppleScript alloc] initWithSource:@"tell
application \"System Events\" to attach action to
\"Internal:private:tmp:TestFolder:\" using
\"Internal:private:tmp:RGB-Finder.scpt\""];
[folderActionScript executeAndReturnError:nil];
Works great. It is a little slow on the first execution.. Guessing
that is because it has to compile the script first. Since the paths
arent static I cant really per-compile the scripts.
Thanks again for your help..
Mark
On Jun 25, 2006, at 4:56 AM, Pablo Pons Bordes wrote:
I don't know if there is any API to do this but if you are able to do
this by an apple script what you can do is execute the apple script
from the COCOA code with the "NSAppleScript" Class. I think that it
is the easy and fasted way if you know to do with apple script
good luck
Pablo Pons
El 24/06/2006, a las 19:40, Mark Butler escribió:
First I am really new to this... So I guess I am beggin for a little
slack. Maybe all I really need is pointers to the right documentation.
Is there a way to attach a "folder action" to a directory with an
objective c call... Or do I need to call an applescript to do that.
I can attach a folder action by doing an applescript like
Tell application "System Events" to attach action to myFolder using
myActionScriptFile
Mark
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden