Copy "Artist - Song name" to the clipboard
The aim is to assign a shortcut for copying the artist and name of currently playing or selected song from iTunes to the clipboard.
How it can be done?
MacBook Pro, OS X Mountain Lion (10.8.2)
The aim is to assign a shortcut for copying the artist and name of currently playing or selected song from iTunes to the clipboard.
How it can be done?
MacBook Pro, OS X Mountain Lion (10.8.2)
I usually recommend not manipulating the clipboard via AppleScript - not because it can't be done (it can), but because there are usually better options.
In any case, since I don't know what you're ultimately trying to do...
tell application "iTunes"
if player state is playing then
set TA to artist of (get current track)
set TN to name of (get current track)
set the clipboard toTA & " - " & TN
end if
end tell
The issue is assigning this to a key shortcut, which AppleScript can't do on its own.
I usually recommend not manipulating the clipboard via AppleScript - not because it can't be done (it can), but because there are usually better options.
In any case, since I don't know what you're ultimately trying to do...
tell application "iTunes"
if player state is playing then
set TA to artist of (get current track)
set TN to name of (get current track)
set the clipboard toTA & " - " & TN
end if
end tell
The issue is assigning this to a key shortcut, which AppleScript can't do on its own.
You could use FastScripts (free for up to 10 keyboard shortcuts) to assign the script to a key shortcut.
Case #1 – Copy current track's "Artist Name - Track Title" to the clipboard by pressing shortcut.
Applescript + FastScripts do it but I don't want an extra app in Login Items.
Case #2 – Copy selected tracks' "Artist Name - Track Title" to the clipboard by pressing shortcut.
That's what I have in clipboard after pressing cmd + c (unnecessary info: album, duration, etc.)
Thats what I want in clipboard after pressing shortcut (e.g., alt + c or cmd + c if possible)
I'm not sure what you're saying here.
I've already provided an example of how to extract the data you want, and I've already explained that AppleScript cannot launch/respond to arbitrary key presses on its own - for that you need some other software.
Try this:
set theInfos to ""
tell application "iTunes"
repeat with thisItem in selection
set theInfos to theInfos & artist of thisItem & " - " & name of thisItem & return
end repeat
end tell
set the clipboard totheInfos
Copy "Artist - Song name" to the clipboard