• 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: iTunes, NSAppleScript, and timeout
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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
  • Prev by Date: Re: Open for access with write permission
  • Next by Date: Two quick questions
  • Previous by thread: RE: iTunes, NSAppleScript, and timeout
  • Next by thread: Finding iCal Repeating Events
  • Index(es):
    • Date
    • Thread