+ Antworten
Ergebnis 1 bis 4 von 4

Thema: [AppleScript] Prüfen, ob iTunes auf entfernter Maschine läuft

  1. #1
    Grahams Jubiläumsapfel Kampfgnom ist auf einem guten Weg
    Registriert
    06.2007
    Beiträge
    14

    [AppleScript] Prüfen, ob iTunes auf entfernter Maschine läuft

    Hi,

    Man kann ja iTunes auf entfernten Mac OS X Rechnern steuern:
    Code:
    tell application "iTunes" of machine "eppc://192.168.1.200" to next track
    
    Nun würde ich gerne überprüfen,

    Code:
    ob das entfernte iTunes läuft
        dann das entfernte iTunes steuern
    wenn nein
       dann das lokale iTunes steuern.
    
    Meine ersten Ansätze:

    Code:
    on getHost()
        tell application "System Events" of machine "eppc://192.168.1.200" to set isRunning to (name of processes) contains "iTunes"
        if isRunning then
            return "eppc://192.168.1.200"
        else
            return "eppc://192.168.1.201"
        end if
    end getHost
    try
            set theHost to getHost()
            tell application "iTunes" of machine theHost to playpause
    end try
    
    Allerdings funktioniert das nicht, weil wenn hinter "of machine" eine Variable und kein String-Literal folgt, denkt er dass playpause eine Variable wäre

    Komme mit Applescript nicht wirklich klar. Es ist einfach nicht logisch.

    Code:
    #funktioniert:
    tell application "iTunes" of machine "eppc://192.168.1.200" to playpause
    
    #funktioniert nicht!
    set theHost to "eppc://192.168.1.200"
    tell application "iTunes" of machine theHost to playpause
    


    Und dann ist auch noch die Undo-Funktion vom Scripteditor verbuggt... alter schwede

    Danke

  2. #2
    Boskop sedna ist ein Lichtstreif am Horizont sedna ist ein Lichtstreif am Horizont sedna ist ein Lichtstreif am Horizont sedna ist ein Lichtstreif am Horizont sedna ist ein Lichtstreif am Horizont sedna ist ein Lichtstreif am Horizont sedna ist ein Lichtstreif am Horizont sedna ist ein Lichtstreif am Horizont sedna ist ein Lichtstreif am Horizont sedna ist ein Lichtstreif am Horizont Avatar von sedna
    Registriert
    10.2008
    Beiträge
    211
    Hallo Kampfgnom!

    Hihi! Manchmal kann man wirklich verzweifeln. Kopf hoch!

    Code:
    set theHost to "eppc://192.168.1.200"
    using terms from application "iTunes"
        tell application "iTunes" of machine theHost to playpause
    end using terms from
    
    Mir ist übrigens noch gar nicht aufgefallen, daß die Undo Funktion buggy ist.
    Was stimmt denn da nicht?

    Sedna

  3. #3
    Grahams Jubiläumsapfel Kampfgnom ist auf einem guten Weg
    Registriert
    06.2007
    Beiträge
    14
    EDIT: Siehe unten...
    ################################################
    Ich verstehe zwar nicht was dieses Konstrukt soll, will es aber auch lieber nicht wissen. Hinterher mag ich noch Apple-Script *schauder*
    Auf jeden Fall danke, es funktioniert nun:
    Code:
    on checkProcess()
        tell application "System Events" of machine "eppc://192.168.1.200"
            set isRunning to ((application processes whose (name is equal to "iTunes")) count)
        end tell
        if isRunning is greater than 0 then
            return true
        else
            return false
        end if
    end checkProcess
    
    on getHost()
        if checkProcess() then
            return "eppc://192.168.1.200"
        else
            return "eppc://192.168.1.201"
        end if
    end getHost
    
    set theHost to getHost()
    using terms from application "iTunes"
        tell application "iTunes" of machine theHost to playpause
    end using terms from
    
    Etwas umständlich, aber hey es läuft...

    Was verbuggt ist an der Undo-Funktion:
    Nachdem ich ein paar mal Apfel-Z gedrückt habe kommt das hier dabei raus:
    Code:
    on checkProcess()
        tell application "System Evenachine "eppc://192.168.1.200"
            set isRunning to ((application processes whose (name is equal to "iTunes")) count)
        end tell
        if isRunning is greater than 0 then
            return tru//192.168.1.200"e
        else
            return f//192.168.1.201"alse
        end if
    end checkProcess
    
    on getHost()
        if ceppc://192.168.1.201"
        end if
    end g from application "iTunes"
        tell application "iTuneachine theHost to playpause
    end using terms from
    
    Manchmal passiert auch einfach nichts, was meistens besser ist, weil Redo funktioniert bei mir auch nicht. Hab schon lange nicht mehr neugestartet und auch den Scripteditor seit ein paar Tagen am laufen. Kann also nicht sagen, ob das ganze reproduzierbar ist.

    Danke nochmal
    ################################################
    EDIT:
    Hm Applescript scheint nicht deterministisch zu sein. Das Script funktioniert eine zeitlang (5 Minuten). Jetzt sagt er mir:
    System Events got an error: Cannot find process on host
    Was mach ich denn nun?

  4. #4
    Grahams Jubiläumsapfel Kampfgnom ist auf einem guten Weg
    Registriert
    06.2007
    Beiträge
    14
    Ich Doppelposte mal um die Übersicht zu erhalten. Es funktioniert nun endgültig (meine Änderungen in Rot):
    Code:
    set myHost to "eppc://192.168.1.200"
    on checkProcess()
        try
            tell application "System Events" of machine myHost
                set isRunning to ((application processes whose (name is equal to "iTunes")) count)
            end tell
            if isRunning is greater than 0 then
                return true
            else
                return false
            end if
        on error
            return false
        end try
    end checkProcess
    
    on getHost()
        if checkProcess() then
            return "eppc://192.168.1.200"
        else
            return "eppc://192.168.1.201"
        end if
    end getHost
    
    set theHost to getHost()
    using terms from application "iTunes"
        tell application "iTunes" of machine theHost to playpause
    end using terms from
    
    Warum funktioniert das jetzt und vorher nicht? Semantisch ist es genau das gleiche

+ Antworten

Ähnliche Themen

  1. Kein entfernter Zugriff über Front Row möglich
    Von luettmatten im Forum OS X
    Antworten: 19
    Letzter Beitrag: 24.08.2007, 11:42
  2. itunes und last.fm mit applescript koppeln?
    Von trust_us_24 im Forum OS X-Developer & AppleScript
    Antworten: 19
    Letzter Beitrag: 23.01.2007, 14:28
  3. svn Repository+entfernter Server commiten
    Von cellardoor im Forum Web-Programmierung
    Antworten: 11
    Letzter Beitrag: 07.01.2007, 18:11
  4. Problem mit Applescript und iTunes
    Von Medico im Forum OS X
    Antworten: 0
    Letzter Beitrag: 15.12.2006, 10:54
  5. Brauche AppleScript für iTunes
    Von Stalefish im Forum OS X-Developer & AppleScript
    Antworten: 12
    Letzter Beitrag: 08.12.2006, 13:13

Berechtigungen

  • Es ist dir nicht erlaubt, neue Themen zu verfassen.
  • Es ist dir nicht erlaubt, auf Beiträge zu antworten.
  • Es ist dir nicht erlaubt, Anhänge hochzuladen.
  • Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.