Calling AppleScripts With Arguments

| | Comments (0)
This works now (in my local code, I won't release it for a couple of weeks probably):

use Mac::OSA::Simple;
 
my $script = compile_applescript(<<"EOS");
on \xC7event abcd1234\xC8 (trackname, foo)
    tell application "iTunes"
        play (first track of library playlist 1 whose name is trackname)
        return [artist of current track, foo]
    end tell
end \xC7event abcd1234\xC8
EOS
 
print join "|", $script->call('abcd', '1234', ["I Hung My Head", "garble!"]);

Of course, you could load a compiled AppleScript from disk instead of compiling one in memory, but it is easier to demonstrate it like this. use.perl.org

Leave a comment

<pudge/*> (pronounced "PudgeGlob") is thousands of posts over many years by Pudge.

"It is the common fate of the indolent to see their rights become a prey to the active. The condition upon which God hath given liberty to man is eternal vigilance; which condition if he break, servitude is at once the consequence of his crime and the punishment of his guilt."

About this Entry

This page contains a single entry by pudge published on June 5, 2003 6:43 PM.

Mac::Stuff was the previous entry in this site.

Part of the Problem is the next entry in this site.

Find recent content on the main index or look in the archives to find all content.