Jump to content

Ramiro

Member
  • Posts

    6
  • Joined

  • Last visited

Posts posted by Ramiro

  1. Thanks a lot RodgerWW, you gave me the answer I was looking for (and thanks to "Lri" of course). Here is my new version of the script :

     

    tell application "System Preferences"
    	reveal anchor "output" of pane id "com.apple.preference.sound"
    end tell
    tell application "System Events" to tell process "System Preferences"
    	tell tab group 1 of window "Son"
    		click radio button "Sortie"
    		if (selected of row 3 of table 1 of scroll area 1) then
    			set selected of row 4 of table 1 of scroll area 1 to true
    			set deviceselected to "HEADSET"
    return "HEADSET"
    		else
    			set selected of row 3 of table 1 of scroll area 1 to true
    			set deviceselected to "MAC"
    return "MAC"
    		end if
    	end tell
    end tell
    quit application "System Preferences"
    

     

    - With that I don't need anymore to have a separate script to tell application System Preferences to quit !

    - I don't have anymore the System Preferences pane which open and pop-up on the screen !

     

    - If you have an english system (like most of you I think), you will have to change "SON" by "SOUND" and "SORTIE" by "OUTPUT"

    - Also, you will have to change "ROW 4" by the number corresponding to the sound output you want to be selected. Same thing for the "Else" where you have "ROW 3". You can find which "number" it is for you by "control-click" the sound icon on your menu bar : here you'll find the list of all your sound output options in order (1,2,3...).

     

     

    And here is the new link to download the new resulting workflow if you wish : https://www.box.com/s/79iprwo8nehs0v7bzin6

    Hope you will like it ;-)

  2. I'd like a copy of this and would love to see a way to mute the volume included.

     

    Ok... not sure how to share things... but I have a try with my Box.com account : https://www.box.com/s/yydcplhdj7vzt3dhqhly

     

    That's the "Toggle Sound Output Workflow", hope you like it.

     

    Concerning a way to mute the volume that's something to include in the "script"... it's possible and I think it already exist a workflow on the forum concerning that. If you search you will find it I think.

  3. my last post was done during the night and I was missing some sleep. This morning I found the solution to my issue. If anyone have suggestions to simplify that I would be pleased to know :

     

    fqRUhEx.png

     

    and here is the correct code of the first script :

     

     

    tell application "System Preferences"
    activate
    	set current pane to pane "com.apple.preference.sound"
    end tell
    
    tell application "System Events"
    	tell application process "System Preferences"
    		tell tab group 1 of window "Son"
    			click radio button "Sortie"
    			if (selected of row 3 of table 1 of scroll area 1) then
    				set selected of row 4 of table 1 of scroll area 1 to true
    				set deviceselected to "HEADSET"
    return "HEADSET"
    			else
    				set selected of row 3 of table 1 of scroll area 1 to true
    				set deviceselected to "MAC"
    return "MAC"
    			end if
    		end tell
    	end tell
    end tell
    tell application "System Preferences" to quit
    

     

    As you can see my error of yesterday night was in forgetting the 2 "return" ... so the script didn't send any information to Notification Center ! (When awake it's obvious).

     

    You should wonder why I have a second script inside the workflow ? The reason is because when running my workflow it seems that the first script stop to answer after the "end if" line. So it never quit the "System Preferences" pane ! (maybe I'm not totally awake and I'm missing something obvious ?).

    So that's why I have a second script... just having :

     

    tell application "System Preferences" to quit
    

     

    That's it.

     

    So what this simple workflow do exactly :

     

    - I press on F6

    - System Preferences open briefly on my display and automatically change the sound output from my Mac's speaker to my headset (or vice-versa)

    - System Preferences close and I get a nice looking Notification Center pop-up saying "TOGGLE SOUND OUTPUT : HEADSET" (or "MAC")

     

     

     

     

    And here is my questions for you :

     

    - Do you see any way to simplify everything ? 

    - Is there a way to have the "system preferences" pane to be invisible on the display when running the script ?

     

    I don't need to change from or to other sound outputs sources. The only other one I would sometimes use is "HDMI" ... but I will think about an other simple workflow using "launch XBMC media center" as a trigger to "Toggle sound output to HDMI". What do you think ? 

  4. Hello everyone,

     

    here is my first post on this forum.

     

    I know there is some other similar posts on the forum... I've read them... but they don't do exactly what I'm looking for. Let me explain myself clearly and you will understand :

     

    I have an "old" applescript which toggle the sound output on a press of a hotkey (F7) between 2 different outputs : my display's speakers or my headset. As a result it also send a notification to Growl saying something like "Sound output changed to...".

     

    Here is the actual AppleScript :

     

    tell application "System Preferences"
    	activate
    	set current pane to pane "com.apple.preference.sound"
    end tell
    
    tell application "System Events"
    	tell application process "System Preferences"
    		tell tab group 1 of window "Son"
    			click radio button "Sortie"
    			if (selected of row 2 of table 1 of scroll area 1) then
    				set selected of row 3 of table 1 of scroll area 1 to true
    				set deviceselected to "HEADSET"
    			else
    				set selected of row 2 of table 1 of scroll area 1 to true
    				set deviceselected to "MAC"
    			end if
    		end tell
    	end tell
    end tell
    
    tell application "System Preferences" to quit
    
    tell application "Growl"
    	set the allNotificationsList to {"Sound Notification"}
    	set the enabledNotificationsList to {"Sound Notification"}
    	
    	register as application "Toggle Sound Output" all notifications allNotificationsList default notifications enabledNotificationsList icon of application "System Events"
    	
    	notify with name "Sound Notification" title "Audio Output" description deviceselected application name "Toggle Sound Output"
    	
    end tell

     

     

     

    This script worked well in Alfred 1 as a "trigger" but today I'm a proud new owner of the great Alfred V2 and I'd like to directly integrate this script into a Workflow. And here starts my problems :

     

    - I can integrate the script to activate after the press of an hotkey... but I'm unable to output a notification center visual result

    or

    - I can output a notification center result but without any {query} (of course) so without any usefull information.

     

    I tried some of the workflows I've found on your nice forum (Next Audio Output Device...) but what they do is that they ask me to type "o u t p u t"... then to use my keyboard or mouse to choose which sound output I want. It's "long" ! I'd like to press my hotkey and "boum" automatically switch from headsets to display's speakers and vice-versa ! 

     

    As you understood at this point, I define myself as "noob" concerning scripting/programming. I usually succeed to get my solution by copying/pasting parts of codes from different scripts... Alfred is so cool I'd like to have more learning about that, that's also the reason I post here :-)

     

     

    Sorry for the long message. Hope someone would give me some solution.

     

    Thanks

×
×
  • Create New...