re-setting the MIDI settings with Applescript

Jim Ault JimAultWins at yahoo.com
Fri Oct 27 20:45:23 EDT 2006


On 10/27/06 11:43 AM, "Claire Bradin Siskin" <cbsiskin+ at pitt.edu> wrote:
> Here is the Applescript that we are using:
> <full quote below>

Thanks for the script!  My use of System Events is very limited since there
is so much trial and error involved.

For those who don't get it, Audio MIDI Setup is an app that does not have
Applescripting built-in beyond the core suite of commands.  With Applescript
we can tell the app to 'activate' and thus open, then use part of OSX to
work with the components of the interface that is showing.

We are telling OSX System Events to >>>
tell pop up button 8 to become choice "iMic USB audio system"
tell pop up button 1 to become choice "2ch-16bit"
tell pop up button 5 to become choice "iMic USB audio system"
tell pop up button 6 to become choice "iMic USB audio system"
tell pop up button 7 to become choice "iMic USB audio system"
tell pop up button 9 to become choice "2ch-16bit"
tell application "Audio MIDI Setup" to quit

System Events can work with a wide variety of apps that don't have more than
the core suite of commands.  Even applets running inside Safari can be read
and controlled.  Using this, you can read the text on any button, the text
lines of a scrolling field, the menu header, or all the choices in a drop
down menu (pop up button).  It is pretty cool to send a click to a button in
a java applet written by someone who isn't even thinking of a Mac.  Safari
renders the applet components available to System Events. (I think that's
how it works)

Anyway, I really appreciate the tech tip for the Audio MIDI Setup app.  This
is definitely going in my tips and tricks archive.

Thanks Claire!

Jim Ault
Las Vegas  ------
PS  Hmmm, but CAN IT WORK with Print Dialog boxes/ Page Setup to set paper
orientation, etc?  Perhaps it can.

put "tell SystemEvents/tell app Rev/delay 1.0/
tell pop up button 99/click/ click menu item "legal" of menu 1
tell button "OK"/click" into cmd

do cmd as AppleScript  --without waiting (can't remember how to do this)
revShowPrintDialog true ,false -- shows only Page Setup dialog
--the click from the AppleScript will dismiss the dialog--

--definitely untested.  Probably one little thing that will stop this, since
so many people would like to see this work :-)
----------------------------------------------------------------------

On 10/27/06 11:43 AM, "Claire Bradin Siskin" <cbsiskin+ at pitt.edu> wrote:

> Here is the Applescript that we are using:
> 
> -------------------------------
> 
> on setPopUpXToY(x, y)
> tell application "System Events"
> tell application process "Audio MIDI Setup"
> tell window "Audio MIDI Setup"
> tell tab group 1
> delay 0.3
> tell pop up button x
> click
> click menu item y of menu 1
> end tell
> end tell
> end tell
> end tell
> end tell
> end setPopUpXToY
> 
> try
> tell application "Audio MIDI Setup" to activate
> 
> setPopUpXToY(8, "iMic USB audio system") -- make sure we're
> setting the properties for the iMic
> setPopUpXToY(1, "2ch-16bit") -- set the audio output format
> setPopUpXToY(5, "iMic USB audio system") -- set the Default Output
> setPopUpXToY(6, "iMic USB audio system") -- set the System Output
> setPopUpXToY(7, "iMic USB audio system") -- set the Default Input
> 
> setPopUpXToY(9, "2ch-16bit") -- set the audio input format
> 
> tell application "Audio MIDI Setup" to quit
> end try
> 
> -------------------------------
> 
> The following procedure should work:
> 
> 1. put the above script in a hidden field called "applescriptField"
> 2. use the following handler: do field "applescriptField" as AppleScript
> 
> Many thanks to Devin Asay for telling me how to do this!





More information about the Use-livecode mailing list