Mac::Glues on Mac OS X

pudge on 2002-03-12T05:19:57

I did some investigation tonight on how to make glues for Mac::Glue from Mac OS X apps. Some observations:

  • We sometimes get the AppleScript terminology data in the aete resource from the files themselves. However, there is no one standard in the apps themselves. iTunes.app has a iTunes.rsrc resource fork file which I could open with MacPerl to create the glue; Internet Explorer.app had a similar file, but it was not a resource fork file, it was a plain data file. And Cocoa apps like Mail.app don't have such a file with aete resource at all.


  • I suspect that, unlike Mac OS, Mac OS X won't have applications that won't respond to the "ascr\gdte" Apple event, which returns the aete data. In other words, maybe we won't have to parse any file data, and just get it via an event (which is what happens for most apps even under Mac OS 9).


  • The observations about being able to get aete data via Apple events doesn't directly apply to Scripting Additions and the "dialect" file. Standard Additions.osax is like Internet Explorer.app ... I need to figure out how to get the data from these things, since we always just opened the resource fork, and that may no longer be feasible. OTOH, maybe it will be. Or maybe I can somehow get the data via some Apple event.


  • So to get the data, I think can just drop a package on the droplet, find $package/Contents/PkgInfo, open it up, get the application's signature ("emal" for Mail.app), and then use that to get the aete data. It worked just fine this way for Mail.app, and I created a usable glue and everything:

    use Mac::Glue; my $mail = new Mac::Glue 'Mail'; $mail->activate; $mail->mailto('mailto:pudge@pobox.com');

    Yes, this is MacPerl running under Classic talking to a Cocoa app running under Mac OS X via Apple events with Mac::Glue. And it works with very little modification of Mac::AETE::App and Mac::AETE::Format::Glue.


  • Not all the problems are so easily solved, of course. There's the Scripting Additions problem mentioned above; there's also potential problems with launching apps, especially by path instead of signature, etc. All will need to be tested and played with in due time.



  • Of course, none of this is entirely useful right now, unless you want to use MacPerl on Mac OS X. The real purpose of this is to know what to do when we can use Mac::Glue under native perl on Mac OS X.



Check out the AppKit docs

Elian on 2002-03-12T14:40:29

Cocoa's got some base AppleScript functionality built into it, and as far as I can tell, pretty much any Cocoa app will do basic AppleScript for free.

Re:Check out the AppKit docs

pudge on 2002-03-12T15:03:15

Yeah, that's all fine; the point here is not whether it can do it, or how it does it, but how I can get the AppleScript terminology information from it. Apparently for Cocoa apps, I have all the work done. But for other Cocoa things, like Cocoa-based Scripting Additions, I am not sure yet; I did look at some of Apple's Cocoa docs, and didn't see much. I am sure there's more there; that part's down lower on my list anyway, though.

If you do come across docs that discuss where on the filesystem the AppleScript terminology is stored for a given Cocoa or Carbon binary, how it is parsed, what format it is in, or how to retrieve it from something else (a la Script Editor), please do let me know. As noted, I mostly have a good handle on it so far from what I can tell -- as I already have a working glue for a Cocoa app! -- but there are still some blind spots.