Board Of Metal
AppleScripts - Druckversion

+- Board Of Metal (https://forum.board-of-metal.org)
+-- Forum: Smalltalk und Diverses (https://forum.board-of-metal.org/forum-4.html)
+--- Forum: Multimedia- & Freizeitforum (https://forum.board-of-metal.org/forum-27.html)
+--- Thema: AppleScripts (/thread-9386.html)



AppleScripts - padrak - 07.03.2011

Nachdem ich ewig auf der Suche nach einem brauchbaren AMIP Ersatz unter OSX war, bin ich über diverse Quellen auf eine Lösung gestoßen.

Mit AppleScripts kann man nicht nur so etwas in der Art erstellen, sondern - nach kurzem Ersteindruck - eine ganze Menge mehr.

Das Skript für AMIP ist noch nicht ganz perfekt, ich bitte also um Verbesserungsvorschläge bzw. Lösungen.

Natürlich kann hier jeder Skripts vorstellen, die das Leben unter OSX vereinfachen können.

AMIP Ersatz:
Zitat:on run
try
tell application "iTunes"
set songTitle to the name of the current track
set songArtist to the artist of the current track
set songAlbum to the album of the current track
set songYear to the year of the current track
set the clipboard to "/me lauscht:" & the songArtist & " - " & songTitle & " \"" & songAlbum & ", " & songYear & "\""
end tell
end try
end run

Dieses Skript kopiert folgendes in die Zwischenablage: (Bsp.)
./me lauscht: Crippled Black Phoenix - Troublemaker "I,Vigilante, 2010"

Was jetzt noch u.a. zum totalen Glück fehlt ist, dass automatisch dieser Text in das gerade aktive Feld kopiert wird (CMD+V). Als Basis dafür habe ich folgendes gefunden:

Zitat:tell application "System Events"
tell application "iTunes" to activate
keystroke "v" using {command down}
end tell

Ich weiß nicht, warum man den Befehl "tell application" 2x benötigt (sonst Fehlermeldung). "System Events" funktioniert auf jeden Fall nur bei Programmfokus, also nicht global. Tausch von "SE" gegen "iTunes" führt auch zum Fehler. Hier bin ich noch nicht weitergekommen...


RE: AppleScripts - malde - 08.03.2011

Das ist ja dann schon GUI scripting, ich glaub eher nicht, dass das ohne Focus geht :hmm:


RE: AppleScripts - Azathoth - 08.03.2011

Code:
on run
    try
        tell application "iTunes"
            set songTitle to the name of the current track
            set songArtist to the artist of the current track
            set songAlbum to the album of the current track
            set songYear to the year of the current track
            set the clipboard to "/me lauscht:" & the songArtist & " - " & songTitle & " \"" & songAlbum & ", " & songYear & "\""
        end tell
    end try
    try
        set the clipboard to Unicode text of (the clipboard as record)
    on error errMsg
        display dialog errMsg
    end try
    tell application "System Events"
        key code 9 using {command down}
    end tell
end run



RE: AppleScripts - padrak - 08.03.2011

Funzt, danke! Thumbs

Ich hatte nur übersehen, dass ich beim Scripttest mit der Play Taste noch im Scriptfenster war und da hat er dann den Song unten dazugefügt. Smile

Benutze auch die Kombo CTRL+CMD+M. Geht bisher in allen Progs, wo ich das Script benötige, ohne Probleme.

@Aza
Darf ich die Lösung verbreiten? Also zumindest im Macuser Thread, wo mir schon häufiger geholfen wurde.


RE: AppleScripts - Azathoth - 08.03.2011

Ja klar kannst du das. Ist ja zum Großteil von dir.
...aber nur, wenn du damit einverstanden bist, dass ichs auch in meinem Blog verbreite Smile


RE: AppleScripts - padrak - 08.03.2011

Tu dem Smile


RE: AppleScripts - malde - 08.03.2011

Get a room Smile

Ich werd aza's "ich hab nen neuen post in meinem blog" dann mal retweeten Smile


RE: AppleScripts - Azathoth - 08.03.2011

Ok, geht schon malde Smile
Thx! Usofa


RE: AppleScripts - Azathoth - 08.03.2011

Wow, das geht aber schnell Smile