Mac::Stuff
I've had several requests before to make OSA scripts accept arguments. For example, in Mac::OSA::Simple, you can do, for a saved script:
So I mostly have it worked out that you will be able to pass arguments to your compiled AppleScript. What the code will look like, with the AppleScript:
And yes, I know, Mac::Carbon is still slow when loading the extensions, in some cases. I'll work on that this summer, too. :-)
tell application "iTunes"This:
play
end tell
my $play = load_osa_script('itunes_play');But what if you want to play a specific track? You don't want to recompile your script, because that is inefficient (it can take awhile to compile an AppleScript, plus you don't want little AppleScripts all over the place).
$play->execute;
So I mostly have it worked out that you will be able to pass arguments to your compiled AppleScript. What the code will look like, with the AppleScript:
on «event abcd1234» (trackname)and the Perl code:
tell application "iTunes"
play (first track of library playlist 1 whose name is trackname)
end tell
end «event abcd1234»
my $play = load_osa_script('itunes_play');And on the command line or whatever, you could have simply:
$play->call('abcd ', '1234', 'Pearls Before Swine');
% iplay "Pearls Before Swine"That's the plan, anyway. I have it working (the low-level stuff). I found a bug in Mac::OSA::OSADoEvent where the reply event was not getting filled out, so it was failing, so it will require a newer Mac::Carbon. I'll do it sometime this summer.
And yes, I know, Mac::Carbon is still slow when loading the extensions, in some cases. I'll work on that this summer, too.
Now Playing: Most Likely You Go Your Way And I'll Go Mine - Bob Dylan (Biograph)
Leave a comment