Cheater's Guide to Writing AppleEvent Descriptors

I pursue a variety of routes to figure out the codes for AEs, but in this case, I snooped on Script Editor sending
     tell application "Finder" to get disks
To snoop, I launch Script Editor from like this:
    [dogbert:~] guyer% setenv AEDebug 1
    [dogbert:~] guyer% setenv AEDebugSends 1
    [dogbert:~] guyer% setenv AEDebugReceives 1
    [dogbert:~] guyer% /Applications/AppleScript/Script\\ Editor
After executing the script, a bunch of garbage will stream by in, and toward the end you'll see:
    AE2000 (28217): Sending an event:
    ------oo start of event oo------
    { 1 } 'aevt':  core/getd (ppc ){
              return id: 1849229319 (0x6e390007)
         transaction id: 0 (0x0)
      interaction level: 64 (0x40)
         reply required: 1 (0x1)
                 remote: 0 (0x0)
        { 2 } 'psn ':  8 bytes {
          { 0x0, 0x900001 } (Finder)
      optional attributes:
        { 1 } 'reco':  - 1 items {
          key 'csig' - 
            { 1 } 'magn':  4 bytes {
              65536l (0x10000)

      event data:
        { 1 } 'aevt':  - 1 items {
          key '----' - 
            { 1 } 'obj ':  - 4 items {
              key 'form' - 
                { 1 } 'enum':  4 bytes {
              key 'want' - 
                { 1 } 'type':  4 bytes {
              key 'seld' - 
                { 1 } 'abso':  4 bytes {
                  'all '
              key 'from' - 
                { -1 } 'null':  null descriptor
I've been doing this for awhile, so I know to ignore most of it. The corresponding TclAE call is
    tclAE::send -r 'MACS' core getd ---- {obj {form:indx, want:type(cdis), seld:abso('all '), from:'null'()}}

Recently, Eric Williams released a little app called AE Monitor. It'll snoop on AE traffic and dump it in a variety of formats, including TclAE's (it's not quite right, but that's my fault; I didn't have the time to test it when he sent it to me; but the basic output should get you close).

'aete' Resources

Even with Capture AE, it's handy to be able to read 'aete' resources (if for no other reason, to decipher what you just blindly copied into your Tcl® statements). Resourcerer has a template to open 'aete' resources and you can decompile them with Rez. If you can manage to find it, Yuji Hachiya of Apple Japan wrote an 'aete' editor for ResEdit. It would appear, though, that Apple has hired the Mossad to hunt down and destroy every copy of this utility (IÕve seen complaints about it, but it's perfectly adequate for reading 'aete' resources).

Although this probably seems like a lot of work, I assure you that it's far preferable to the hunt-and-peck alternative. There's no reason that this methodology won't work with other scriptable applications, either, but I take no responsibility for the implosion of your monitor.

Copyright © 1998Š2007 Jonathan E. Guyer
All rights reserved.

Last modified Tuesday, July 10, 2007 10:18:56 PM

Valid CSS! Valid HTML 4.0!