MAX and Applescript
Hello,
been trying to write a patch using the shell object to send out applescript commands ( mostly GUI scripting ). Im a bit familiar with applescript but it seems some of the syntax is a bit different when using the shell object in max, as ill send out some applescript commands from applescripts i have previously written and work, but when sent via the shell object they dont seem to work. im wondering if anyone knows of some resurces for applescript syntax from max's shell external, i looked around for a bit, but didnt really find anything of use.
thanks,
Mike
Quote: !Include wrote on Thu, 14 June 2007 03:11
----------------------------------------------------
> been trying to write a patch using the shell object to send out
> applescript commands ( mostly GUI scripting ). Im a bit familiar
> with applescript but it seems some of the syntax is a bit
> different when using the shell object in max
----------------------------------------------------
Hi Mike,
Take a look at this recent topic called "Au~ scripting" and search for 'osascript' inside:
About the interface elements, I suggest to study the scripting possibilities of [thispatcher] object.
Bye,
Philippe
if you don't mind moving away from the shell object, you may want to look into tap.tools. it does cost money, but perhaps, tap.applescript may do what you're looking for without an unfamiliar syntax.
m
Quote: Philippe Gruchet wrote on Wed, 13 June 2007 22:53
----------------------------------------------------
> Quote: !Include wrote on Thu, 14 June 2007 03:11
> ----------------------------------------------------
> > been trying to write a patch using the shell object to send out
> > applescript commands ( mostly GUI scripting ). Im a bit familiar
> > with applescript but it seems some of the syntax is a bit
> > different when using the shell object in max
> ----------------------------------------------------
>
> Hi Mike,
>
> Take a look at this recent topic called "Au~ scripting" and search for 'osascript' inside:
>
> About the interface elements, I suggest to study the scripting possibilities of [thispatcher] object.
>
> Bye,
> Philippe
>
----------------------------------------------------
Thanks for your response. So basically the shell object will process anything with proper osascript syntax? Wierd for some reason i cant get any osascript sent key combinations to work. im basically tryin to pass a keycombo ( cmnd + c ) to the shell object with no luck. I can tell system processes to activate Live the application to receive the key command- that works fine. Ive tried a bunch of different things to get the key combo to work, but nothing yet. I have universal access enabled in system prefs. here is what i have if you dont mind taking a look:
osascript -e 'tell application ""System Events"" to tell process "Live" to keystroke "c" using {command down}'
ive also tried using the menu as i found in your Au~ script ( your au script works for me in max by the way:
'tell application |System Events| to tell process |Live| to click menu item 4 of menu 3 of menu bar 1'
but replacing it with the proper menu numbers. Still no luck.
I tried various combinations of both of the above with no luck. Id be greatful for any help on this matter.
Thanks,
mike
>> Quote: !Include wrote on Thu, 14 June 2007 03:11
>> ----------------------------------------------------
>>> been trying to write a patch using the shell object to send out
>>> applescript commands ( mostly GUI scripting ). Im a bit familiar
>>> with applescript but it seems some of the syntax is a bit
>>> different when using the shell object in max
>> ----------------------------------------------------
>>> Quote: Philippe Gruchet wrote on Wed, 13 June 2007 22:53
>>
>> Take a look at this recent topic called "Au~ scripting" and search
>> for 'osascript' inside:
>> About the interface elements, I suggest to study the scripting
>> possibilities of [thispatcher] object.
> ----------------------------------------------------
> So basically the shell object will process anything with proper
> osascript syntax?
Basically, yes.
> Weird for some reason i cant get any osascript sent key
> combinations to work. im basically tryin to pass a keycombo ( cmnd
> + c ) to the shell object with no luck. I can tell system processes
> to activate Live the application to receive the key command- that
> works fine. Ive tried a bunch of different things to get the key
> combo to work, but nothing yet. I have universal access enabled in
> system prefs. here is what i have if you dont mind taking a look:
>
> osascript -e 'tell application ""System Events"" to tell process
> "Live" to keystroke "c" using {command down}'
I suggest to escape all double-quote characters by using the syntax
you'll find in my examples.
Tell first to activate the targeted application. A simple example
that displays the Finder's Clipboard from Max.
I'm using there [prepend osascript -e] when I need several lines of
scripts.
> ive also tried using the menu as i found in your Au~ script ( your
> au script works for me in max by the way:
>
> 'tell application |System Events| to tell process |Live| to click
> menu item 4 of menu 3 of menu bar 1'
> but replacing it with the proper menu numbers. Still no luck.
Try this one:
You can also replace the menu numbers with the proper names as strings:
osascript -e 'tell application |System Events| to tell process |
MaxMSP| to click menu item 6 of menu 4 of menu bar 1'
Becomes:
osascript -e 'tell application |System Events| to tell process |
MaxMSP| to click menu item |Paste| of menu |Edit| of menu bar 1'
HTH,
Philippe
many thanks again Philippe.!. is there any reason for the 1000ms Delay? The Patch only seems to have an effect in Live when the Delay > 350ms.
Quote: !Include wrote on Sun, 17 June 2007 14:28
----------------------------------------------------
> is there any reason for the 1000ms Delay? The Patch only
> seems to have an effect in Live when the Delay > 350ms.
----------------------------------------------------
Yes, 350 to 500 seems a good range for an inter-application scripting. When a such script doesn't work, just increase the delay(s) between each statement.
Bye