Air-Tunes Speaker via Apple Skript switchen

Code zum markieren einmal anklicken Code im Skript-Editor öffnen

–©hubionmac.com 18.12.2008

— GUI-Skript mit dem die aktuelle Air-Tunes ausgabe verändert wird,

— die aktuelle Airtunes-Lautsprecher-Auswahl werden quasi 

activate application “iTunes”

tell application “System Events”

get system attribute “sysv”

if result is greater than or equal to 4144 then — Mac OS X 10.3.0

if UI elements enabled then

tell application process “iTunes”

if (name of button 15 of window “iTunes” as text) ≠ “” then

set noe to false

click button 15 of window “iTunes” –Den ITunes Lautsprecher Button drücken

delay 0.25

— in der Liste ganz nach unten gehene (mehrere Lautsprecher auswählen Menüpunkt 

repeat with i from 1 to 5

key code 125

end repeat

keystroke return

try

repeat with i from 1 to (count of every UI element of window 1)

tell UI element i of window 1

set rowcount to count of rows

if rowcount > 0 then

if (value of checkbox 1 of row rowcount) as integer = 0 then

–dieser part beugt einer Fehlermeldung vor… 

–welcher? einfach mal diesen if-Block entfernen und Du wirst sehen =)

click checkbox 1 of row rowcount

set rowcount to rowcount – 1

end if

repeat with rownr from 1 to rowcount

click checkbox 1 of row rownr

end repeat

end if

end tell

end repeat

end try

keystroke “w” using command down

else

set noe to true

end if

end tell

else

beep

display dialog “GUI Scripting is not enabled” & return & return & “Open System Preferences and check Enable Access for Assistive Devices in the Universal Access preference pane, then run this script again.” with icon stop

if button returned of result is “OK” then

tell application “System Preferences”

activate

set current pane to pane “com.apple.preference.universalaccess”

end tell

end if

end if

else

beep

display dialog “This computer cannot run this script” & return & return & “The script uses GUI Scripting technology, which requires an upgrade to Mac OS X 10.3 Panther or newer.” with icon caution buttons {“Quit”} default button “Quit”

end if

end tell

if noe = true then

tell application “iTunes” to display dialog “nö, keine Airtunes Lautsprecher angeschlossen bzw. kein Button da, wo man so etwas auswählen könnt :-/”

end if

Läuft bis iTunes 9… Eine Lösung für iTunes 10 hat fall-line parat.

4 thoughts on “Air-Tunes Speaker via Apple Skript switchen

  1. kirchhofer rainer says:
    Code zum markieren einmal anklicken Code im Skript-Editor öffnen

    tell application “iTunes”

    –activate

    set visible of window “Multiple speakers” to true

    set {X, y} to position of window “Multiple speakers”

    end tell

    tell application “System Events”

    get system attribute “sysv”

    if result is greater than or equal to 4144 then — Mac OS X 10.3.0

    if UI elements enabled then

    tell application process “iTunes”

    repeat with i from 1 to 5

    key code 125

    end repeat

    keystroke return

    try

    repeat with i from 1 to (count of every UI element of window 1)

    tell UI element i of window 1

    set rowcount to count of rows

    if rowcount > 0 then

    if (value of checkbox 1 of row rowcount) as integer = 0 then

    –dieser part beugt einer Fehlermeldung vor…

    –welcher? einfach mal diesen if-Block entfernen und Du wirst sehen =)

    click checkbox 1 of row rowcount

    set rowcount to rowcount — 1

    end if

    repeat with rownr from 1 to rowcount

    click checkbox 1 of row rownr

    end repeat

    end if

    end tell

    end repeat

    end try

    –keystroke “w” using command down

    end tell

    else

    beep

    display dialog “GUI Scripting is not enabled” & return & return & “Open System Preferences and check Enable Access for Assistive Devices in the Universal Access preference pane, then run this script again.” with icon stop

    if button returned of result is “OK” then

    tell application “System Preferences”

    activate

    set current pane to pane “com.apple.preference.universalaccess”

    end tell

    end if

    end if

    else

    beep

    display dialog “This computer cannot run this script” & return & return & “The script uses GUI Scripting technology, which requires an upgrade to Mac OS X 10.3 Panther or newer.” with icon caution buttons {“Quit”} default button “Quit”

    end if

    end tell

  2. fall-line says:

    Here is an updated version for iTunes 10, with comments in English for anyone who is interested.

    http://fall-line.com/2010/09/control-airplayairtunes-feature-of-itunes-with-applescript/

    Cheers

  3. Tino says:

    Hi, so ein Script suche ich schon eeeewig! Kann mir jemand kurz erklären, was mit dem Script ganz genau machbar ist?
    Wollte es gerade mal probieren, aber beim copy&paste läuft wohl einiges schief :(

  4. […] ursprüngliche Version konnte mit iTunes 8 und 9 noch funktionieren… mit iTunes 10 hat sich das GUI wieder etwas […]

Leave a Reply