Zurück   Apfeltalk > Pro Foren > OS X-Developer & AppleScript

Antwort
 
Optionen Thema durchsuchen Ansicht
Alt 04.11.2008, 00:42   #1
Erdapfel
 
Registriert seit: 06.2007
Beiträge: 5
Kampfgnom ist auf einem guten Weg
[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
Kampfgnom ist offline   Mit Zitat antworten
Alt 04.11.2008, 01:21   #2
Elstar
 
Benutzerbild von sedna
 
Registriert seit: 10.2008
Beiträge: 96
sedna wird früher oder später berühmtsedna wird früher oder später berühmtsedna wird früher oder später berühmtsedna wird früher oder später berühmtsedna wird früher oder später berühmt
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
__________________
ᓴᓐᓇ
sedna ist offline   Mit Zitat antworten
Alt 04.11.2008, 13:23   #3
Erdapfel
 
Registriert seit: 06.2007
Beiträge: 5
Kampfgnom ist auf einem guten Weg
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:
Zitat:
System Events got an error: Cannot find process on host
Was mach ich denn nun?
Kampfgnom ist offline   Mit Zitat antworten
Alt 04.11.2008, 16:01   #4
Erdapfel
 
Registriert seit: 06.2007
Beiträge: 5
Kampfgnom ist auf einem guten Weg
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
Kampfgnom ist offline   Mit Zitat antworten
Antwort

Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist An.
Smileys sind An.
[IMG] Code ist An.
HTML-Code ist Aus.
Trackbacks are Aus
Pingbacks are Aus
Refbacks are Aus


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



Alle Zeitangaben in WEZ +2. Es ist jetzt 11:33 Uhr.


©2003-2009 Apfeltalk