FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister   ProfileProfile    Log inLog in   RSS Feed

Switching between Sound Output devices

 
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Mac
View previous topic :: View next topic  
Author Message
Gobbledigook
Newbie


Joined: 17 Feb 2005
Posts: 2

PostPosted: Mon Mar 06, 2006 7:19 pm    Post subject: Switching between Sound Output devices Reply with quote

Hi,

Currently I have my Cube in my workroom which is hooked up to Yamaha Cavit through USB, but I also have my Cube hooked up to my stereo in my living room via USB to an Onkyo DAC.
I am looking for a way to tell my Cube to switch between these two sound output devices through clicker. I have gotten to the point where I can invoke a choice menu on my Cube through clicker, but the choice doesn't show up on my phone.

Basically what I am looking for is a Sound Output switcher script.

Any help/hints would be greatly appreciated.

The script I want to show up on my phone is:


tell application "System Preferences" to activate
tell application "System Events"
get properties
tell process "System Preferences"
click menu item "Sound" of menu "View" of menu bar 1
delay 2
set theRows to every row of table 1 of scroll area 1 of ¬
tab group 1 of window "sound"
set theOutputs to {} as list
repeat with aRow in theRows
copy (value of text field 1 of aRow as text) to the end of theOutputs
end repeat
tell application "Finder"
activate
set desiredOutput to display dialog ¬
"Choose Sound Output: " buttons theOutputs default button "USB Diigtal Audio Processor"
end tell
repeat with aRow in theRows
if (value of text field 1 of aRow as text) is equal to ¬
(button returned of desiredOutput as text) then
set selected of aRow to true
exit repeat
end if
end repeat
end tell
end tell
tell application "System Preferences" to quit
Back to top
View user's profile Send private message
Mytzlscript
Newbie


Joined: 29 Mar 2006
Posts: 9
Location: St. Paul, MN

PostPosted: Thu Mar 30, 2006 7:31 pm    Post subject: Reply with quote

Try this:

[quote][color=blue][b]property[/b][/color] [color=green]lisDevices[/color] : {"Internal speakers", "USB Digtal Audio Processor"}

[color=blue][b]using terms from[/b][/color] [color=blue]application[/color] "SEC Helper"
     
     [color=blue][b]on[/b][/color] [color=blue]process invoke[/color] [color=green]a_terminal[/color]
          [color=blue][b]tell[/b][/color] [color=green]a_terminal[/color]
               [color=blue][b]set[/b][/color] [color=green]w[/color] [color=blue][b]to[/b][/color] [color=blue]make[/color] [color=blue]new[/color] [color=blue]option list dialog[/color] [color=blue]with properties[/color] {[color=blue]title[/color]:"Set Sound To"}
               [color=blue][b]set[/b][/color] [color=blue]item labels[/color] [color=blue][b]of[/b][/color] [color=green]w[/color] [color=blue][b]to[/b][/color] [color=green]lisDevices[/color]
               --[color=olive]               set value of w to 2[/color]
               [color=blue]push[/color] [color=green]w[/color]
          [color=blue][b]end[/b][/color] [color=blue][b]tell[/b][/color]
     [color=blue][b]end[/b][/color] [color=blue]process invoke[/color]
     
     [color=blue][b]on[/b][/color] [color=blue]process dialog ok[/color] [color=green]the_dialog[/color]
          [color=blue][b]set[/b][/color] [color=green]intChoice[/color] [color=blue][b]to[/b][/color] [color=blue][b]the[/b][/color] [color=blue]value[/color] [color=blue][b]of[/b][/color] [color=green]the_dialog[/color] [color=blue][b]as[/b][/color] [color=blue]string[/color]
          [color=blue][b]set[/b][/color] [color=green]theDevice[/color] [color=blue][b]to[/b][/color] ([color=blue]item[/color] [color=green]intChoice[/color] [color=blue][b]of[/b][/color] [color=green]lisDevices[/color])
          [color=blue][b]try[/b][/color]
               [color=blue][b]my[/b][/color] [color=green]setOutput[/color]([color=green]theDevice[/color])
               [color=blue]show screen[/color] [color=blue]message[/color] ("Set sound output to " & [color=green]theDevice[/color] [color=blue][b]as[/b][/color] [color=blue]text[/color])
          [color=blue][b]on[/b][/color] [color=blue][b]error[/b][/color] [color=green]err[/color]
               [color=blue]show screen[/color] [color=blue]message[/color] ("Couldn't set sound output because: " & [color=green]err[/color] [color=blue][b]as[/b][/color] [color=blue]text[/color])
          [color=blue][b]end[/b][/color] [color=blue][b]try[/b][/color]
     [color=blue][b]end[/b][/color] [color=blue]process dialog ok[/color]
     
     [color=blue][b]on[/b][/color] [color=blue]process dialog cancel[/color] [color=green]the_dialog[/color]
          [color=blue]show screen[/color] [color=blue]message[/color] "cancelled"
     [color=blue][b]end[/b][/color] [color=blue]process dialog cancel[/color]
     
[color=blue][b]end[/b][/color] [color=blue][b]using terms from[/b][/color]


[color=blue][b]on[/b][/color] [color=green]setOutput[/color]([color=green]aDevice[/color])
     [color=blue][b]tell[/b][/color] [color=blue]application[/color] "System Preferences" [color=blue][b]to[/b][/color] [color=blue]activate[/color]
     [color=blue][b]tell[/b][/color] [color=blue]application[/color] "System Events"
          [color=blue][b]tell[/b][/color] [color=blue]process[/color] "System Preferences"
               [color=blue]click[/color] [color=blue]menu item[/color] "Sound" [color=blue][b]of[/b][/color] [color=blue]menu[/color] "View" [color=blue][b]of[/b][/color] [color=blue]menu bar[/color] 1
               [color=blue]delay[/color] 2
               --[color=olive]I had to also click the output tab[/color]
               [color=blue]click[/color] [color=blue]radio button[/color] "Output" [color=blue][b]of[/b][/color] [color=blue]tab group[/color] 1 [color=blue][b]of[/b][/color] [color=blue]window[/color] "sound"
               [color=blue]delay[/color] 2
               [color=blue][b]set[/b][/color] [color=green]theRows[/color] [color=blue][b]to[/b][/color] [color=blue][b]every[/b][/color] [color=blue]row[/color] [color=blue][b]of[/b][/color] [color=blue]table[/color] 1 [color=blue][b]of[/b][/color] [color=blue]scroll area[/color] 1 [color=blue][b]of[/b][/color] [color=blue]tab group[/color] 1 [color=blue][b]of[/b][/color] [color=blue]window[/color] "sound"
               [color=blue][b]repeat[/b][/color] [color=blue][b]with[/b][/color] [color=green]aRow[/color] [color=blue][b]in[/b][/color] [color=green]theRows[/color]
                    [color=blue][b]if[/b][/color] ([color=blue]value[/color] [color=blue][b]of[/b][/color] [color=blue]text field[/color] 1 [color=blue][b]of[/b][/color] [color=green]aRow[/color] [color=blue][b]as[/b][/color] [color=blue]text[/color]) [color=blue][b]is[/b][/color] [color=blue][b]equal to[/b][/color] [color=green]aDevice[/color] [color=blue][b]then[/b][/color]
                         [color=blue][b]set[/b][/color] [color=blue]selected[/color] [color=blue][b]of[/b][/color] [color=green]aRow[/color] [color=blue][b]to[/b][/color] [color=blue]true[/color]
                         [color=blue][b]exit[/b][/color] [color=blue][b]repeat[/b][/color]
                    [color=blue][b]end[/b][/color] [color=blue][b]if[/b][/color]
               [color=blue][b]end[/b][/color] [color=blue][b]repeat[/b][/color]
          [color=blue][b]end[/b][/color] [color=blue][b]tell[/b][/color]
     [color=blue][b]end[/b][/color] [color=blue][b]tell[/b][/color]
     [color=blue][b]tell[/b][/color] [color=blue]application[/color] "System Preferences" [color=blue][b]to[/b][/color] [color=blue]quit[/color]
[color=blue][b]end[/b][/color] [color=green]setOutput[/color][/quote]

-------------------------
[This script was automatically tagged for color coded syntax by [url=http://homepage.mac.com/jonn8/as/]Convert Script to Markup Code[/url]]
Back to top
View user's profile Send private message Visit poster's website AIM Address
Gobbledigook
Newbie


Joined: 17 Feb 2005
Posts: 2

PostPosted: Thu Mar 30, 2006 7:54 pm    Post subject: Reply with quote

Mytzlscript, you are an absolute STAR!!!!!
I only had to change the names of the devices, and it works like a charm.

You have made my life a lot easier with this. I thank you from the bottom from my heart, and good charma is on it's way.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Mac All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group