Re: iTunes, NSAppleScript, and timeout
Re: iTunes, NSAppleScript, and timeout
- Subject: Re: iTunes, NSAppleScript, and timeout
- From: has <email@hidden>
- Date: Fri, 23 Mar 2007 10:35:04 +0000
patrick machielse wrote:
or 2. ditch AppleScript and talk to iTunes directly from ObjC via
the low-level
Apple Event Manager API (tedious as hell for anything non-trivial) or
via a high-level API such as objc-appscript [1] (see my sig).
I had come across objc-appscript before, but ended up using the
eyetunes framework, since it is designed for iTunes. Then I needed to
add playlists and I was back with AppleScript...
Not used eyetunes so can't comment on how good it is. However, objc-
appscript generates a glue for the entire iTunes dictionary, so you
can do anything in appscript that you can do from AppleScript, plus a
bit more.
The problem with AppleScript timeouts is that AppleScripts must be
run on the main thread, so short of spinning off a new process, the
user will be looking at the spinning beach ball for 2 minutes.
You can send Apple events from non-main threads if you want. If you
need to get a reply event, allocate a Mach port to receive it, e.g.
from TN2053:
mach_port_t port;
mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &port);
AEPutAttributePtr(&myEvent, keyReplyPortAttr, typeMachPort, &port,
sizeof(port));
AESendMessage(&event, &reply, kAEWaitReply, kAEDefaultTimeout);
mach_port_destroy(port);
Another option is to use asynchronous events: install an event
handler to receive reply events (kCoreEventClass + kAEAnswer) and
send your events with the kAEQueueReply flag.
HTH
has
--
http://appscript.sourceforge.net
http://rb-appscript.rubyforge.org
http://appscript.sourceforge.net/objc-appscript.html
_______________________________________________
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