Hallo, Gast! Registrieren

Themabewertung:
  • 1 Bewertung(en) - 5 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
AppleScripts
#1
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...
SATAN WORSHIPPING DOOM
Antworten
#2
Das ist ja dann schon GUI scripting, ich glaub eher nicht, dass das ohne Focus geht :hmm:
yeah, well, you know, that's just, like, your opinion, man
Antworten
#3
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
I hate my flesh.
It's dimension poisoned my soul with doubt.
It made me question the essence of the "I".
Antworten
#4
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.
SATAN WORSHIPPING DOOM
Antworten
#5
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
I hate my flesh.
It's dimension poisoned my soul with doubt.
It made me question the essence of the "I".
Antworten
#6
Tu dem Smile
SATAN WORSHIPPING DOOM
Antworten
#7
Get a room Smile

Ich werd aza's "ich hab nen neuen post in meinem blog" dann mal retweeten Smile
yeah, well, you know, that's just, like, your opinion, man
Antworten
#8
Ok, geht schon malde Smile
Thx! Usofa
I hate my flesh.
It's dimension poisoned my soul with doubt.
It made me question the essence of the "I".
Antworten
#9
Wow, das geht aber schnell Smile
I hate my flesh.
It's dimension poisoned my soul with doubt.
It made me question the essence of the "I".
Antworten


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste