If one song selected in iTunes do this, otherwise do that

Hello.
I am creating a macro for iTunes.
Is there a way to tell KM if one song is selected do this otherwise (more than one song selected) do that?
Thanks

You could use KM to trigger an AppleScript which determines how many songs are selected, and based on that, triggers the KM macro of choice (or directly implements the desired actions in AppleScript).

1 Like

Thanks RickO for your suggestion. Appreciate your help.
I’m still learning basic AppleScript, so for me it’s not an option yet. I was hoping there is a way I can do it only with KM.

No time like the present to start learning a little AppleScript. Try this:

try
   tell application "iTunes"
	set theSelection to selection
	set theCount to count of theSelection
	if theCount = 0 then display dialog "This Macro Requires at least one track to be selected."
	if theCount = 1 then tell application "Keyboard Maestro Engine" to do script "Macro Name #1"
	if theCount > 1 then tell application "Keyboard Maestro Engine" to do script "Macro Name #2"	
   end tell
end try

Insert the (unique) names of your KM macros for “Macro Name #n” above.
This won’t differentiate between music track selections and other selections, but it’s a start.

1 Like

Thanks for “being stubborn” RickO. :slight_smile:
I will try later and will tell you how it went.
Again, appreciate your help.

Tried.
Works exactly as I wanted.
Thanks a lot for your time and patience!
Have a great evening.
Saul