AppleScript के साथ ध्वनि आउटपुट डिवाइस नाम प्राप्त करें


1

मैं AppleScript के साथ वर्तमान ध्वनि आउटपुट डिवाइस नाम कैसे प्राप्त कर सकता हूं?

उदाहरण के लिए, मेरी में सिस्टम वरीयताएँ: ध्वनि फलक "आंतरिक स्पीकर" वर्तमान में चयनित है। मुझे केवल उस डिवाइस का नाम - "आंतरिक स्पीकर" या "हेडफ़ोन" या "ब्लूटूथ स्पीकर" प्राप्त करना है - जो भी वर्तमान में उपयोग में है।

(मुझे किसी अन्य डिवाइस के लिए स्विचर / चेंजर की आवश्यकता नहीं है।)

जवाबों:


0

SwitchAudioSource http://code.google.com/p/switchaudio-osx/ एक कमांड-लाइन यूटिलिटी है जो लायन और मेटन लायन के तहत काम करती है (मुझे नए OS X संस्करणों के बारे में पता नहीं है)। यदि यह आपके लिए काम करता है, तो आप इसे AppleScript में उपयोग कर सकते हैं, निम्नानुसार है:

on run

    set theSwitch to "path_to_SwitchAudioSource"
    set theLine to "Current audio output device is:"

    do shell script theSwitch & " -c"
    display dialog theLine & return & return & result buttons {"OK"}

end run

यह एक छोटा सा उपयोग है! और यह महान काम करता है, यहां तक ​​कि योसेमाइट के तहत भी। धन्यवाद!
schmelding

@Apspsis SwitchAudioSource टिप के लिए धन्यवाद - वास्तव में अच्छा है। मैंने उपयोग किया है BetterTouchTool स्थिति दिखाने और स्थिति बदलने के लिए कुछ टचबार बटन और विजेट जोड़ने के लिए। मैंने कोड डाल दिया है GitHub
gmorrell

1

बस थोड़ा और अधिक मदद करने के लिए:

अपने मुख्य उपयोगकर्ता निर्देशिका / होम // में 'बिन' नाम की एक निर्देशिका बनाएं और उसमें स्विचएडियोस्रोस डालें।

यहाँ कुछ AppleScript हैं जो दो स्रोतों के बीच आगे और पीछे स्विच करते हैं, मेरे मैक मिनी (एक लैपटॉप अलग होना चाहिए) के पीछे डिफ़ॉल्ट 'हेडफ़ोन' मिनी जैक आउटपुट है, और मेरा सेन्हेसर यूएसबी हेडेस्ट है।

मुझे me कैप्टन ऑब्जेक्टिव ’कहो, लेकिन यहाँ तुम जाओ:

`रन पर

set theSwitch to "~/bin/SwitchAudioSource"
set theSource to do shell script theSwitch & " -c"

if theSource = "Built-in Output" then
    do shell script theSwitch & " -s \"Sennheiser USB headset\""
else
    do shell script theSwitch & " -s \"Built-in Output\""
end if

अंत भागो `


0

कुछ इस तरह।

tell application "System Preferences"
    reveal pane id "com.apple.preference.sound"
end tell

tell application "System Events"
    tell application process "System Preferences"
        tell tab group 1 of window "Sound"
            click radio button "Output"
            tell table 1 of scroll area 1
                set selected_row to (first UI element whose selected is true)
                set currentOutput to value of text field 1 of selected_row as text
                display dialog currentOutput
            end tell
        end tell
    end tell
end tell

if application "System Preferences" is running then
    tell application "System Preferences" to quit
end if

2
धन्यवाद! वहाँ एक तरह से यह सिस्टम वरीयताएँ लॉन्च करने के लिए बिना है?
schmelding
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.