Die ursprüngliche Version konnte mit iTunes 8 und 9 noch funktionieren… mit iTunes 10 hat sich das GUI wieder etwas geändert. Fall-Line hatte sich der Aktualisierung bereits angenommen, diese Version sollte aber unter jeder System-Sprache funktionieren.
Zudem hat das Skript noch ein kleines Update erfahren. Man kann eine Konfiguration vorgeben oder ohne Vorgabe die aktuelle Einstellung in iTunes einfach nur switchen…

--Airtunes - Switch - Config - script
(**hubionmac.com 10.09.2010
for addition info: http://hubionmac.com/wordpress/?p=2303
orig. Version by http://fall-line.com/2010/09/control-airplayairtunes-feature-of-itunes-with-applescript/
if check_these und uncheck_these = {} then your
Airtunes-Config will be switched the other way around….
Makes use of GUI-Skripting, hopefully Apple will add native AppleScript-Support in iTunes for
Airtunes some day 
**)
set check_these to {} --something like {"Name of Your Air-TunesDevice"}
set uncheck_these to {} --something like {"Computer"}
my check_gui_scripting_is_active()
my check_if_iTunes_window_visible()
my press_speaker_button_and_open_all_speakers()
my check_boxes_and_close_window(check_these, uncheck_these)
on press_speaker_button_and_open_all_speakers()
    tell application "iTunes"
        activate
        tell application "System Events"
            tell application process "iTunes"
                click button 8 of window "iTunes" --Press the iTunes 10 Speaker Button
                key code 125 using {command down} --this is essentiall hitting page down (command + down arrow)
                delay 1
                keystroke return
                delay 1
            end tell
        end tell
    end tell
end press_speaker_button_and_open_all_speakers
on check_boxes_and_close_window(check_these, uncheck_these)
    --if check_these und uncheck_these = {} then your
    --Airtunes-Config will be switched the other way around….
    tell application "iTunes"
        activate
        tell application "System Events"
            tell application process "iTunes"
                tell window 1
                    tell table 1 of scroll area 1
                        set check_computer_allowed to false
                        repeat with i from (count of every row) to 1 by -1 -- Itterate through each row, looking for the criteria below
                            set rowcount to count of rows
                            set a to rowcount
                            if rowcount > 0 then
                                tell group 1 of row i
                                    activate -- Drill into the object group of each row, so we don’t have to later.
                                    -- If "Speaker in Room A" is turned off (value of checkbox 1 = 0), turn it on. Otherwise do nothing
                                    if check_these is {} and uncheck_these = {} then
                                        if i > 1 and value of checkbox 1 as integer = 0 then
                                            set check_computer_allowed to true
                                        end if
                                        if i > 1 then
                                            click checkbox 1
                                        else
                                            if check_computer_allowed is true then
                                                click checkbox 1
                                            end if
                                        end if
                                    else
                                        if (description of checkbox 1) is in check_these and value of checkbox 1 as integer = 0 then
                                            click checkbox 1
                                        end if
                                        if (description of checkbox 1) is in uncheck_these and value of checkbox 1 as integer = 1 then
                                            click checkbox 1
                                            set a to (description of checkbox 1)
                                        end if
                                    end if
                                end tell
                            end if
                        end repeat
                    end tell
                end tell
            end tell
        end tell
        close window 1
    end tell
end check_boxes_and_close_window
on check_if_iTunes_window_visible()
    tell application "iTunes"
        activate
        tell application "System Events"
            tell application process "iTunes"
                --check if itunes Window is frontmost
                if (count of every window) = 0 or (name of window 1 ≠ "iTunes") then
                    keystroke "1" using {command down, option down}
                end if
            end tell
        end tell
    end tell
end check_if_iTunes_window_visible
to check_gui_scripting_is_active()
    tell application "System Events" to set isUIScriptingEnabled to UI elements enabled
    if isUIScriptingEnabled = false then
        tell application "System Preferences"
            activate
            set current pane to pane "com.apple.preference.universalaccess"
            display dialog "Your system is not properly configured to run this script.
         Please select the \"Enable access for assistive devices\"
         checkbox and trigger the script again to proceed."
            return
        end tell
    end if
end check_gui_scripting_is_active

Add a comment

Next Post Previous Post