Mac::OSA::Simple is now updated to work with Mac OS X, using Mac::Carbon.
It has some minor fixes that also apply to MacPerl.

Mac::OSA::Simple provides simple access to Mac::OSA.  At its most basic
level, it provides an applescript(SCRIPT) function for compiling and
executing an AppleScript, and returning the result, just like
MacPerl::DoAppleScript(SCRIPT).

But OSA is not just AppleScript; there is also the osa_script(COMP, SCRIPT)
function for executing arbitrary OSA scripts, such as with the OSAShell
component and the JavaScript component.

        $x = osa_sscript('Shll', 'ls');
        $y = `ls`;
        # $x eq $y;

OK, maybe that is not extraordinarily useful, but it's just an example. :-)

Also, Mac::OSA::Simple allows compiling of a script into a Perl object,
which can then be executed, saved, and decompiled, with
compile_applescript() and compile_osa_script().

        $script = compile_applescript('tell app "Finder" to activate');
        $script->save("annoyingscript");
        print $script->source, "\n";
        $script->execute, sleep 2 while 1;  # ha ha ha

And you can load scripts, either from the filesystem, or from an script in
memory:

        $script2 = load_osa_script("annoyingscript");
        $script3 = load_osa_script($script2->compiled);

This works with any compiled AppleScript/OSA script, not just those created
by Mac::OSA::Simple.


Example of when to use Mac::OSA::Simple instead of DoAppleScript():

        # slow
        MacPerl::DoAppleScript('tell app "iTunes" to pause');

        # fast
        $pause_script = load_osa_script($pause_path);
        $pause_script->execute;


Coming next is a port of Mac::AppleEvents::Simple to Mac OS X.

Also note the new address of my Perl modules:

        http://projects.pudge.net/

And I am still entertaining volunteer efforts for tests for Mac::Carbon.
:)  Contact me if you want to help.

Enjoy,

-- 
Chris Nandor                      [EMAIL PROTECTED]    http://pudge.net/
Open Source Development Network    [EMAIL PROTECTED]     http://osdn.com/

Reply via email to