I’m puzzled.
Some messages dated 2015/08/14 appear before mine dated 2015/08/10.
I made a few changes to your script and, more important, I added comments upon its behavior
tell application "System Events"
if exists disk item "/usr/local/bin/cliclick" then
set p2CliClick to "/usr/local/bin/cliclick"
else if exists disk item "/usr/bin/cliclick" then
set p2CliClick to "/usr/bin/cliclick"
else
error "It seems that Cliclick is not installed"
end if
end tell
tell application "iTunes" to activate
tell application "System Events"
tell process "iTunes"
set frontmost to true
tell window 1
log (get class of UI elements) --> (*radio group, radio group, pop up button, button, button, button, slider, scroll area, button, text field, button, button, button, button, splitter group*)
log (get name of pop up button 1) -- "Morceaux"
click pop up button 1 # named "Morceaux" or "Albums" or "Artistes" . in French
tell pop over 1 of pop up button 1
repeat until it exists
delay 0.1
end repeat
log (get class of UI elements)
# If name of pop up button 1 is "Morceaux"
--> (*table, pop up button, static text, pop up button, checkbox, checkbox, slider*)
# If name of pop up button 1 is "Albums"
--> (*table, pop up button, static text, pop up button, static text, checkbox, pop up button*)
tell table 1 to tell item 2 of rows
set its selected to true
set {x, y} to its position
set {w, h} to its size
--click in the pop up button entitled "Albums"
do shell script p2CliClick & " c:" & (x + w div 2) & "," & (y + h div 2)
end tell # table 1
end tell # pop over.
delay 0.3 # Here it enter an infinite loop if the delay is smaller.
log (get name of pop up button 1) --> Now it's "Albums"
click pop up button 1 # open pop up again
tell pop over 1 of pop up button 1
repeat until it exists
delay 0.1
end repeat
tell pop up button 1 # open pop up sorting
set {x, y} to its position
set {w, h} to its size
log (get its value) --> "Artiste"
--click in the pop up button entitled "Artists"
do shell script p2CliClick & " c:" & (x + w div 2) & "," & (y + h div 2)
end tell # pop up
delay 0.1
-- make sure that the first entry is selected
repeat 6 times
do shell script p2CliClick & " kp:arrow-up"
end repeat
-- select second entry
do shell script p2CliClick & " kp:arrow-down"
delay 0.1
do shell script p2CliClick & " kp:return"
delay 0.1
if value of checkbox 1 is 0 then # if show cover is not selected ?????????
tell checkbox 1
set its selected to true
set {x, y} to its position
set {w, h} to its size
--click the checkbox
do shell script p2CliClick & " c:" & (x + w div 2) & "," & (y + h div 2)
end tell # checkbox
end if
log (get title of checkbox 1) --> (*Afficher les ajouts récents*)
log (get value of pop up button 2) --> (*Année*)
log (get value of pop up button 3) --> (*de l'année dernière*)
end tell # pop over.
click pop up button 1 # close pop up
end tell # window 1
end tell # process
end tell # application
As you may see, the check box which you describe as entitled “Show cover” is named “Afficher les ajouts récents” in French.
I’m not sure that checking it is useful here.
I made change upon instructions triggering cliclick because you installed it as “/usr/local/bin/cliclick”
when my sample was triggering it at “/usr/bin/cliclick”
Yvan KOENIG running Yosemite 10.10.5 in French (VALLAURIS, France) dimanche 16 août 2015 20:37:00