How can I tell iTunes to stop playing a song?
The AppleScript for this is pretty simple:
tell application "iTunes" to stop
You can make this easily accessible by creating a Service.
Open Automator and create a new document. Select the Service document type. Set the Service receives: menu to no input
. Drag in a Run AppleScript
module and paste that code into its text box. Save the service and give it a name.
You'll now be able to activate it by going to the current app's menu and choosing Services-> Stop iTunes (or whatever you named the service).
You can assign a keyboard shortcut by going to System Preferences-> Keyboard-> Services, finding the service (it should be under General at the bottom) and adding a shortcut.
In Applescript, the script tell app "iTunes" to stop
should work.
And the pause button is only available in the currently playing playlist; anywhere else, it will be stop.
There are three correct answers here. I've tried two of them to see that they work. Command-period stops the currently playing song and so does Option-Pause. I've seen the Command period solution before but cannot remember where I found it. The Option-pause solution is new to me, but I'm glad to have two solutions. Maybe I'll remember at least one of them. ;-)
The Apple Script solution probably works too, but it makes things more difficult then they need to be, given the other two solutions. That said, at some time in the distant past I created a Scripts folder in the ~/Library/iTunes folder and placed some scripts in it. As a result I have a Scripts icon next to the Help menu in iTunes. That's where I'd put the script if I wanted to use it. No need to create a service or keyboard shortcut to it. By the way, I tested this option: I quit iTunes and then put the Scripts folder in the trash. I launched iTunes and the scripts item in the menu bar was gone. I quit iTunes and restored the Scripts folder, launched iTunes and there it was again in the menu bar. From this I conclude that anyone can create a Scripts folder for iTunes if they want to. That would be an easier way to use the script it you wanted to go that route. You cannot create a keyboard shortcut for it, though, because the Scripts item in the iTunes menu uses an icon, not a name. I tried it; no go. Hope this answer isn't too long.
Hold the Option key down, while clicking the Pause button.