Choose iTunes Menu Item

I already have the playlist selected in itunes. I want to choose File:Library:Show Duplicate Items

I know this is a “System Events” tell, but not sure how to do it. Any advice appreciated.

Cheers

You may try :

# Long instruction used to get the indexes
my select_SubMenu("iTunes", 3, 12, 10) # Fichier > Bibliothèque > Afficher les doublons

# short instruction to use in real life because it's faster
my selectSubMenu("iTunes", 3, 12, 10)



on selectSubMenu(theApp, mt, mi, ms) # Fichier > Bibliothèque > Afficher les doublons
	activate application theApp
	tell application "System Events" to tell process theApp
		set frontmost to true
		tell menu bar 1 to tell menu bar item mt to ¬
			tell menu 1 to tell menu item mi to tell menu 1 to click menu item ms
	end tell
end selectSubMenu

#=====
(*
useful to get the indexs of the triggered item
my select_SubMenu("iTunes", 3, 12, 10) # Fichier > Bibliothèque > Afficher les doublons
*)
on select_SubMenu(theApp, mt, mi, ms)
	activate application theApp
	tell application "System Events" to tell process theApp
		set frontmost to true
		tell menu bar 1
			get name of menu bar items
			(*{
01 - "Apple", 
02 - "iTunes", 
03 - "Fichier", 
04 - "Édition", 
05 - "Morceau", 
06 - "Présentation", 
07 - "Commandes", 
08 - "Compte", 
09 - "Fenêtre", 
10 - "Aide"
}*)
			get name of menu bar item mt
			-- {"Fichier"}
			tell menu bar item mt to tell menu 1
				get name of menu items
				(* {
				01 - "Nouvelle playlist", 
02 - "Nouvelle playlist à partir de la sélection", 
03 - Nouvelle playlist intelligente…, 
04 - "Nouveau dossier de playlist", 
05 - "Nouvelle playlist Genius", 
06 - missing value, 
07 - "Modifier la playlist", 
08 - "Fermer la fenêtre", 
09 - missing value, 
10 - "Ajouter à la bibliothèque…", 
11 - "Graver la playlist sur un disque", 
12 - "Bibliothèque", 
13 - "Appareils", 
14 - "Partage à domicile", 
15 - missing value, 
16 - "Ouvrir le flux…", 
17 - "S’abonner au podcast…", 
18 - missing value, 
19 - "Afficher dans le Finder", 
20 - "Convertir", 
21 - missing value, 
22 - "Format d’impression…", 
23 - "Imprimer…"
}*)
				get name of menu item mi
				--"Bibliothèque"
				
				tell menu item mi to tell menu 1
					get name of menu items
					(* {
01 - "Mettre à jour la bibliothèque musicale iCloud", 
02 - "Actualiser Genius", 
03 - missing value, 
04 - "Organiser la bibliothèque…", 
05 - "Consolider les fichiers…", 
06 - "Exporter la bibliothèque…" ,
07 - missing value, 
08 - "Importer la playlist…", 
09 - "Exporter la playlist…", 
10 - "Afficher les doublons", 
11 - "Afficher les éléments en double", 
12 - missing value, 
13 - "Obtenir les illustrations d’album", 
14 - "Obtenir les noms de piste"
}*)
					get name of menu item ms
					-- "Afficher les doublons"
					click menu item ms
				end tell -- menu item…
			end tell
		end tell -- menu bar…
	end tell -- System Events
end select_SubMenu

#=====
my select_SubMenu("iTunes", 3, 12, 10) # Fichier > Bibliothèque > Afficher les doublons

Yvan KOENIG running Sierra 10.12.6 in French (VALLAURIS, France) mercredi 2 aout 2017 10:37:35

Hi Yvan. Thanks for the reply.

I’m not trying to get Applescript to do anything more than just choose a menu item. That’s all I want.

File
Library
Show Duplicate Items

Cheers

Doing what you ask requires a lot of instructions.
It’s what my script does.
You may test it to check.

Yvan KOENIG running Sierra 10.12.6 in French (VALLAURIS, France) jeudi 3 aout 2017 19:41:25

Excellent. I took the time to walk through it and saw most of it was comments. I see how it works now.

Cheers

I assumed that my message was clear. select_SubMenu is the “long” version useful to define the indexes to use. selectSubMenu is the compact version to use in real life.

Yvan KOENIG running Sierra 10.12.6 in French (VALLAURIS, France) mardi 8 aout 2017 14:28:26

Hi Yvan, did you get my private message?

No, at this time 2017/08/09 11:15:20 I received nothing.
Maybe your message was delivered in my spam box where I may have missed it.
The best way is to use : k o e n i g . y v a n @ s f r . f r (without the space characters).

Yvan KOENIG running Sierra 10.12.6 in French (VALLAURIS, France) mercredi 9 aout 2017 11:18:22

Oops, I didn’t knew the way personal messages behave in this list.
Happily Nigel Garvey explained me off list.
I will try to retrieve the original thread to see if I may help you.

Yvan KOENIG running Sierra 10.12.6 in French (VALLAURIS, France) mercredi 9 aout 2017 14:04:25

I retrieved the original thread.lease send me a mail using the address given in message #8 so that we may exchange - possibly with attached files - easily.
I need some complementary explanations.

Yvan KOENIG running Sierra 10.12.6 in French (VALLAURIS, France) mercredi 9 aout 2017 14:41:15

Hi Yvan, did you receive my email??