Mac::AppleEvents, Mostly Working
Last night's problem was solved by adding "-lstdc++" to the linker flags. Thanks, Matthias!
So today, I get it working, and I try a simple script:
I also still need to port the AESubDescs (for subdescriptors) and AEStreams (an OO interface to handling Apple event data) stuff, but they are rarely used, and are a lower priority than just getting this to work. I'll be more than happy to add them back in later, if I can.
So today, I get it working, and I try a simple script:
use Mac::AppleEvents;And sure enough, it activates the Finder. This is the equivalent of the AppleScript:
$evt = AEBuildAppleEvent(qw(misc actv sign MACS), -1, 0, "");
AESend($evt, kAENoReply);
tell app "Finder" to activateSweet. I've even tried some more complex things, opening a directory in the Finder, using the Mac::AppleEvents::Simple frontend:
use Mac::AppleEvents::Simple ':all';Or, using aliases:
$evt = build_event(qw(aevt odoc MACS),
q{'----':obj { want:type(cobj), from:null(), form:enum(name), seld:TEXT(@)}}
"Orr:Users:pudge:" # yes, AEGizmos requires HFS paths
);
$evt->send_event(kAENoReply);
use Mac::AppleEvents::Simple ':all';All looks good so far. But, you may ask, why kAENoReply? Sure, I don't need the reply, but why bother not waiting, as per the default? There's the big remaining problem: I can't receive a reply. I have an idle proc that appears to be working -- as is needed to receive a reply -- but it's not getting the event back. I was afraid of this. In Mac OS, you need to set a flag that says your application can receive high-level events (such as Apple events). But how to do this for perl? No idea. Working on a solution, but in the meantime, polishing and playing.
use Mac::Files;
$evt = build_event(qw(aevt odoc MACS), q{'----':alis(@@)}, NewAlias("/Users/pudge/")); $evt->send_event(kAENoReply)'
I also still need to port the AESubDescs (for subdescriptors) and AEStreams (an OO interface to handling Apple event data) stuff, but they are rarely used, and are a lower priority than just getting this to work. I'll be more than happy to add them back in later, if I can.
Now Playing: Found a Home - Jon Gibson (Forever Friends)
Leave a comment