[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] help with bells and whisles?



"arthur" writes Thu, 14 May 1998 19:17:44 -0800:

>I am trying to get sounds in the game when you win. So If anyone knows how
>to do that, I am all ears.

If you have SoundMachine, or maybe something better, you could put the
bells and whistles into files and get AppleScript to call them at the
appropriate moments. This will generally work even if (like SoundMachine)
the application itself is not scriptable. You could write in the MacPerl
script:

    MacPerl::DoAppleScript qq(
        tell application "Finder"
            open file "HD:...:SoundFile.au"
        end tell
    );

You can speed things up a lot by building an AppleEvent. Full details of
how to do this can be found in Chris Nandor's excellent tutorial. It would
look something like:

    #!perl
    use Mac::AppleEvents;

    $f = "HD:...:SoundFile.au";
    $obj = "obj{want:type(file), from:null(), form:name, seld:TEXT(\@)}";

    $evt = AEBuildAppleEvent('aevt', 'odoc', 'sign', 'MACS', 0, 0,
                         "'----':$obj", $f) or die $^E;
    $rep = AESend($evt, kAEWaitReply) or die $^E;

    AEDisposeDesc $evt;
    AEDisposeDesc $rep;

Hope this helps.

Alan Fry




***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch