boolean values in appleevents

Lee Phillips lee at leeHYPHENphillips.org.invalid
Wed Feb 6 16:39:38 EST 2002


   I am trying to learn how to send appleevents with python (because I
want to script applications on the Macintosh and I dislike
AppleScript). I've had good luck with what comes in
Mac/Demo/applescript in MacPython, except that I can't figure out how
to send boolean flags to applications. I guess neither can the authors
of the included example, makedisk.py, that tells Disk Copy to make a
disk image, because their argument, "leave_image_mounted=1", has the
same effect if you change it to "leave_image_mounted=0" : the default,
which is to leave the image mounted. 
   I know that a boolean value is not being sent, because when I
monitor the appleevents with the Capture AE control panel, I see this:

Process("Disk Copy").SendAE "ddsk,Crea,'----':³my disk image², SvAs:fss
(«[long string]»), Moun:1"

where that bit at the end, "Moun:1" or "Moun:0", is ignored by the
receiver (Disk Copy), because it is expecting a boolean. If you send
the command from AppleScript, using

tell application "Disk Copy"
   activate
   create "my disk image" saving as "my disk image.img" with leave
                                  image mounted
end tell

the appleevent that gets sent is this:

Process("Disk Copy").SendAE "ddsk,Crea,'----':³my disk image², SvAs:³my
disk image.img², Moun:'true'(), &subj:'null'()" 

where "Moun:'true'()" or, if you say "without leave image mounted",
"Moun:'fals'()", actually changes what the receiver does. 

   Sorry about the the verboseness. Maybe I should just ask: does
anyone out there actually know how to send boolean values in
appleevents?



More information about the Python-list mailing list