Catalina Reminders, make new list with color? emblem?

How many times would it be necessary to repeat that I can’t run Catalina on my machine.
So I was unable to guess which way to define colors are available in Reminders.
I asked you about that but you never answered (of course you weren’t forced to do that).
So don’t be surprised if I didn’t knew the answer.

Now, thanks to my grand daughter, I know that there is only a single scheme : a “palette” with 12 colored buttons.

We aren’t allowed to define the hexadecimal string describing a color, it’s a property of this one.

The script which I posted in message #11 extracted the colors in an application (“Numbers”) using two of the standard dedicated tools whose French names are :
{“Roue des couleurs”, “Curseurs de couleur”, “Palettes de couleurs”, “Palettes d’images”, “Crayons”, “RCWeb”}
From the palette “Crayons” I select a pencil, grab the name of the color (in fact its description).
Then I switch to the palette “RCWeb” which display the hexadecimal value describing the color as well as its three individual hexadecimal component : R(ed) G(reen) B(lue).

This morning I tried to achieve the same task without switching between palettes using the command do shell script “/usr/local/bin/cliclick cp:” & xCB + wCB div 2 & “,” & yCB + hCB div 2
supposed to return the three individual components as decimal strings.

----------------------------------------------------------------
use AppleScript version "2.5"
use framework "Foundation"
use scripting additions

-- Yvan KOENIG (VALLAURIS, France) lundi 27 avril 2020 20:56:05

----------------------------------------------------------------

property |⌘| : a reference to current application

set reportName to "the_colors Cliclick.txt"
set targetFile to (path to desktop as string) & reportName

tell application "Numbers"
	activate
	tell document 1 to tell sheet 1 to tell table 1
		set selection range to range "B2"
	end tell
end tell

tell application "System Events" to tell process "Numbers"
	set frontmost to true
	set mainWindow to first window whose subrole is "AXStandardWindow"
	tell mainWindow
		-- class of UI elements --> {scroll area, button, scroll area, button, button, scroll area, button, button, radio group, scroll area, button, button, button, menu button, toolbar, tab, static text, static text}
		
		tell radio group 1
			-- class of UI elements --> {radio button, radio button, radio button, radio button}
			-- name of radio buttons --> {"Tableau", "Cellule", "Texte", "Disposition"}
			click radio button 2 --> "Cellule"
		end tell
		(*
		tell scroll area 1
			class of UI elements --> {scroll bar, scroll bar}
		end tell
		tell scroll area 2
			class of UI elements --> {static text}
			value of static text 1 --> "Feuille 1"
		end tell
		tell scroll area 3
			class of UI elements --> --> {static text, static text}
			value of static texts --> {"", ""}
		end tell
		*)
		tell scroll area 4
			-- class of UI elements --> {pop up button, static text, UI element, static text, button, pop up button, static text, image, list, color well, text field, incrementor, pop up button, menu button, button, scroll bar}
			-- help of pop up buttons --> {"Choisissez le format d’affichage des valeurs dans les cellules sélectionnées. ", "Choisissez un type de remplissage.", missing value}
			-- title of buttons--> {"", "Surlignage conditionnel…"}
			set {{xCB, yCB}, {wCB, hCB}} to {position, size} of button 1 -- the one displaying the fill color
			tell pop up button 2
				click it
				tell menu 1
					-- get name of menu items --> {"Aucun", "Remplissage couleur", "Remplissage dégradé", "Remplissage dégradé avancé", "Remplissage par image", "Remplissage image avancé"}
					click menu item 2 --> "Remplissage couleur"
				end tell
			end tell -- pop up button 2
			set {{xCW, yCW}, {wCW, hCW}} to {position, size} of color well 1
		end tell -- scroll area 4
	end tell -- mainWindow
	repeat 10 times
		delay 0.2
		if exists (first window whose subrole is "AXFloatingWindow") then exit repeat
		-- Click in the square at right edge of the color wheel
		tell me to do shell script "/usr/local/bin/cliclick c:" & (xCW + wCW) - (hCW div 2) & "," & yCW + hCW div 2
	end repeat
	set floatingWindow to first window whose subrole is "AXFloatingWindow"
	
	set nbRadioButtons to 48
	set descriptors to {}
	repeat with i from 1 to nbRadioButtons
		tell floatingWindow
			-- class of UI elements --> {splitter group, button, button, button, toolbar, static text}
			tell toolbar 1
				-- class of UI elements --> {button, button, button, button, button, button}
				-- description of buttons --> {"Roue des couleurs", "Curseurs de couleur", "Palettes de couleurs", "Palettes d’images", "Crayons", "RCWeb"}
				click button -2 -- Crayons
			end tell -- toolbar 1
			tell splitter group 1
				-- class of UI elements --> {static text, radio group, slider, static text, text field, splitter, color well, checkbox, scroll area}
				tell radio group 1
					-- class of UI elements --> {radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button, radio button}
					set itsName to accessibility description of radio button i --> the local name of the color
					-- Grab position and size of the radio button ( a pencil )
					set {{xC, yC}, {wC, hC}} to {position, size} of radio button i
					tell me
						-- Really Click it
						do shell script "/usr/local/bin/cliclick c:" & xC + wC div 2 & "," & yC + hC div 2
						-- Peek the color in the ill Color (the color is not the same in every point of the pencil)
						set theColors to do shell script "/usr/local/bin/cliclick cp:" & xCB + wCB div 2 & "," & yCB + hCB div 2
					end tell
				end tell
			end tell -- splitter group 1
			set RGB to ""
			repeat with v in my decoupe(theColors, space)
				set RGB to RGB & my num2hex(v as integer)
			end repeat
			set end of descriptors to itsName & tab & "#" & RGB
		end tell -- mainWindow
	end repeat
end tell -- System Events

my writeArray:descriptors inFile:targetFile

tell application "TextEdit"
	activate
	if exists window reportName then close window reportName
	open targetFile
end tell

#=====

on writeArray:anArray inFile:hfsPath
	set anArray to |⌘|'s NSArray's arrayWithArray:anArray
	set theData to (anArray's componentsJoinedByString:linefeed)
	-- save data to new file
	(theData's writeToURL:(hfsPath as «class furl») atomically:true encoding:(|⌘|'s NSUTF8StringEncoding) |error|:(missing value))
end writeArray:inFile:

#=====

on decoupe(t, d)
	local oTIDs, l
	set {oTIDs, AppleScript's text item delimiters} to {AppleScript's text item delimiters, d}
	set l to text items of t
	set AppleScript's text item delimiters to oTIDs
	return l
end decoupe

#=====

on num2hex(t)
	set hi to t div 16
	set lo to t mod 16
	return (text item (hi + 1) of "0123456789ABCDEF") & (text item (lo + 1) of "0123456789ABCDEF")
end num2hex

#=====

The manual of Cliclick states:
cp:str Will PRINT THE COLOR value at the given screen location.
The color value is printed as three decimal 8-bit values,
representing, in order, red, green, and blue.
Example: “cp:123,456” might print “127 63 0”

Alas the returned values aren’t identical to those returned by the palette delivered by Apple.

Is it clear now ?

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 29 avril 2020 14:55:39

And what about Numbers.app? I said that in Reminders you won’t be able to read color values using GUI scripting.

I have several times solved previously unresolved!!! problems using last instrument - GUI scripting. You should have looked at how some attacked me… They say “You should look for a standard solution”. No any solution from them itself…

Here everything is exactly the opposite. You are trying to replace a normal solution with GUI scripting. This is unfair, and it is unpleasant for me that you have already litter the entire topic, and no one even squeaks.

Thanks Shane.

Honestly, I’m not really interested by the RGB value(s) of the colors defined by the pencils except the fact that it would be useful to know them in an application able to define the color of an object with standard AppleScript instructions.
For instance, we may define 3 properties this way in Numbers which requires the use of GUIScripting for graphical objects.

So, which is the value supposed to be passed, in Reminders, to define the color of a list which after all is the initial question of this thread ?

At this time, I don’t know which values are returned by my script supposed to extract these using cliclick.
KniazidisR posted two lists in which the names are different and the values are different too.

First list :
set colorsRecord to {White:“#FFFFFF”, Silver:“#C0C0C0”, Gray:“#808080”, Black:“#000000”, Red:“#FF0000”, Maroon:“#800000”, Yellow:“#FFFF00”, Olive:“#808000”, Lime:“#00FF00”, Green:“#008000”, Aqua:“#00FFFF”, Teal:“#008080”, Blue:“#0000FF”, Navy:“#000080”, Fuchsia:“#FF00FF”, Purple:“#800080”}

Second list :
#FF2968” – red, … as you see, it is not exactly VGA standard red
#FF9500” – orange
#FFCC00” – yellow
#63DA38” – green
#5AC8FA” – blue
#1BADF8” – dark blue
#5856D6” – indigo
#FF2D55” – pink
#CC73E1” – purple
#A2845E” – brown
#5B626A” – grey
#D9A69F” – rose

As I don’t want to reinvent the wheel, I choose to use the names used by Apple in Reminders and now I wish to know which are the RGB values for these 12 colors.

In fact, at this time I ignore also which colors are named Rose or Pink. Which one is lighter than the other ? My dictionary, like the guy building the localization translate both by Rose which is “frustating”.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 29 avril 2020 15:55:02

So, what are you doing the headings of these 2 lists? Okay, spit… I recently got my permissions to the car, and the numbers, back. Therefore, I just go about my business.

I repeat what I wrote in message #3:
Look in the dedicated dictionary to see if the properties color and/or badge are defined in it.
If they aren’t, I fear that you will have to rely upon GUI scripting to do what you want.

I don’t try to define the color of an object using GUI Scripting.
I try to get the numerical values describing the colors used by Reminders.
To do that I proposed a script able to grab the color names and to extract their RGB values using GUI scripting. It grabs also the names of the emblems.

I assumed that at least the original asker would be fair enough to post what my script returns.
Alas, I saw nothing.

When I asked for infos about the behavior of Reminders, I got a single answer, from someone which doesn’t practice GuiScripting.

It’s what helped me when, at last, I had access to a macBook running Catalina.
Five minutes later the script was ready to use.

I really don’t understand what’s your problem here.
I didn’t criticize your original proposal.
When I wrote message #3 I didn’t knew what you posted in message #2.
It’s true that from my point of view it’s more logical to use a script to extract the required infos than doing that by hand as you did.
It’s my advice, don’t be surprised that I share it.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 29 avril 2020 16:04:45


----------------------------------------------------------------
use AppleScript version "2.5"
use framework "Foundation"
use scripting additions

-- Build an array of the English names of colors used by Reminders starting from the localized names
-- Build an array of the English names of emblems used by Reminders starting from the localized names

-- Yvan KOENIG (VALLAURIS, France) jeudi 30 avril 2020 12:35:02
----------------------------------------------------------------

property |⌘| : a reference to current application

set localizedColors to {"Rouge", "Orange", "Jaune", "Vert", "Bleu clair", "Bleu", "Indigo", "Rose", "Violet", "Marron", "Gris", "Rose"}
set localizedEmblems to {"Sélectionnée, Liste", "Signet", "Repère", "Cadeau", "Gâteau d’anniversaire", "Chapeau de diplômé", "Sac à dos", "Règle et crayon", "Portefeuille", "Carte bancaire", "Billets et pièces", "Haltères", "Personne qui court", "Fourchette et couteau", "Verre à vin", "Pilules et cachets", "Stéthoscope", "Fauteuil", "Maison", "Téléviseur", "Musique", "Ordinateur", "Manette de jeu", "Feuille", "Carotte", "Personne", "Couple", "Famille", "Patte", "Ours en peluche", "Poisson", "Panier de courses", "Caddie", "Cabas", "Ballon de foot", "Baseball", "Basketball", "Football américain", "Raquette de tennis", "Train", "Avion", "Bateau", "Voiture", "Parasol", "Lune", "Soleil", "Goutte d’eau", "Flocon de neige", "Feu", "Valise", "Clé et tournevis", "Ciseaux", "Compas à dessin", "Crochet", "Carré", "Cercle", "Triangle", "Forme de losange", "Cœur", "Étoile"}

set thisLocale to current application's NSLocale's currentLocale()
set myCountryCode to thisLocale's countryCode as text --> "FR"
set myLocaleIdentifier to thisLocale's localeIdentifier as text --> "fr_FR"
set myLanguageCode to thisLocale's languageCode as text --> "fr"

tell application "System Events"
	set forYK to exists folder "resources YK:"
end tell
if not forYK then
	set root to (path to application "Reminders" as text) & "Contents:Resources:"
else
	set root to "resources YK:resources trois:Catalina:Applications:Reminders.app:Contents:Resources:"
end if
set fullTable to "Localizable.strings"

set anURL to (|⌘|'s NSURL's fileURLWithPath:(POSIX path of (root & myLanguageCode & ".lproj:" & fullTable)))
set theDict to (|⌘|'s NSDictionary's dictionaryWithContentsOfURL:anURL)
set theColors to {}
set theEmblems to {}
if theDict is not missing value then
	set theKeys to theDict's allKeys()
	repeat with akey in theKeys
		set aValue to (theDict's valueForKey:akey) as text
		if aValue is in localizedColors then
			set end of theColors to (akey as text) & tab & aValue
		else if aValue is in localizedEmblems then
			set end of theEmblems to (akey as text) & tab & aValue
		end if
	end repeat
end if

my saveList(theColors, "colors for Reminders.txt")
my saveList(theEmblems, "emblems for Reminders.txt")

#=====

on saveList(aList, reportName)
	set theData to my concatlist:aList usingString:linefeed
	-- save data to new file
	set hfsPath to (path to documents folder as text) & reportName
	set targetFile to hfsPath as «class furl»
	(theData's writeToURL:targetFile atomically:true encoding:(|⌘|'s NSUTF8StringEncoding) |error|:(missing value))
	
	tell application "TextEdit"
		activate
		if exists window reportName then close window reportName
		open targetFile
	end tell
end saveList

#=====

on concatlist:theList usingString:d1
	set anArray to current application's NSArray's arrayWithArray:theList
	return (anArray's componentsJoinedByString:d1) -- as text
end concatlist:usingString:

#=====

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 30 avril 2020 12:40:46