Need help with GUI Scripting Audio Midi Setup

I want to read the value of the sampling frequency set by default in Audio Midi Setup.

If there is an easy unix way to gleen this, please let me know. Otherwise, I am trying to get it via GUI scripting. I think I am almost there, but am doing something stupid.

Here is what I have:


tell application "Audio MIDI Setup"
activate
end tell
tell application "System Events"
activate
tell application process "Audio MIDI Setup"
select window 1
select group
select tab group
select group
select combo box
set FrequencyValue to contents of combo box
end tell
end tell


Basically, this comes down to the question of how to extract the default text field from the combo box.

Mac OS X (10.6.4)

Posted on Sep 15, 2010 12:12 PM

Reply
6 replies

Sep 15, 2010 1:17 PM in response to Bill Scott

A quick search didn't turn up any shell scripts for that information, but your GUI method would be something like:
tell application "Audio MIDI Setup" to activate
tell application "System Events" to tell application process "Audio MIDI Setup"
set frequencyValue to value of combo box 1 of group 1 of tab group 1 of group 1 of window "Audio Devices"
end tell

This will only work if the Audio window is being shown.

Sep 15, 2010 9:13 PM in response to Bill Scott

Once you click on the combo box to get the list of items, you can do stuff with the results. The easiest thing would probably be to use the up and down arrows to change the selection, since the text field is not editable. You can compare the list of items with the current value and do something from there - how do you plan to choose the item to change to?

<pre style="
font-family: Monaco, 'Courier New', Courier, monospace;
font-size: 10px;
font-weight: normal;
margin: 0px;
padding: 5px;
border: 1px solid #000000;
width: 720px;
color: #000000;
background-color: #DAFFB6;
overflow: auto;"
title="this text can be pasted into the Script Editor">
tell application "Audio MIDI Setup" to activate

tell application "System Events" to tell application process "Audio MIDI Setup"
set comboBox to combo box 1 of group 1 of tab group 1 of group 1 of window "Audio Devices"
set frequencyValue to value of comboBox -- get current value
click button 1 of comboBox -- perform action "AXPress" to drop the list
set theChoices to value of text fields of list 1 of scroll area 1 of comboBox -- get all the values

-- keystroke (ASCII character 31) -- down arrow
-- keystroke (ASCII character 30) -- up arrow
-- keystroke return -- select and dismiss the list
end tell

activate me
choose from list theChoices default items {frequencyValue} -- just show the results
</pre>

Sep 22, 2010 10:10 AM in response to Bill Scott

With a an extensive amount of help from Red Menace, and some additional input from other users, I now have a working version of this Applescript that does what I want. I've embedded it in a shell script (as an osascript) and run the shell script from an iTunes Visualizer plug-in I hacked from the example code provided in the Visualizer SDK.

nyquist.zsh

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Need help with GUI Scripting Audio Midi Setup

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.