[Pythonmac-SIG] boolean values in appleevents

Lee Phillips lee@lee-phillips.org
Thu, 7 Feb 2002 11:30:00 -0500


    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=3D1", 
has the same effect if you change it to "leave_image_mounted=3D0" : 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 (=AB[long string]=BB), 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 rather than 
an integer. 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?