Saturday, July 4, 2020

#1 2020-04-26 08:57:42 am

johncatalano
Member
Registered: 2014-03-07
Posts: 26

Catalina Reminders, make new list with color? emblem?

The Reminders' AppleScript Dictionary lists color and emblem as list properties.

I'd like to create a list with a specific color and emblem, but the results never turn out how I expect.

Here is my test script.

tell application "Reminders"
    make new list with properties {name:"test", color:"red", emblem:"pin"}
end tell

The list "test" is created, but the color and emblems are the defaults: blue and three bullet lines.

How can I make this work?

What are the color names I can use?

What are the emblem names I can use?

Thank you,

John

Last edited by johncatalano (2020-04-26 08:59:10 am)

Offline

 

#2 2020-04-26 11:17:51 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Catalina Reminders, make new list with color? emblem?

Well, I will help little:

Applescript:


-- 16 standard VGA colors 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"}

-- Here I will add standard names of Reminders.app's emblems, so you can than select what you like
set theEmblemNames to {chair:"lifestyle1", |key|:"bookmarks2", runningMan:"sport6", home:"lifestyle2", car:"transport4", defaultEmblem:"default", plane:"transport2", asterisk:"symbol1", cake:"celebration2"} -- and so on

tell application "Reminders"
   set redList to make new list with properties {name:"Red List", color:colorsRecord's Red, emblem:"bookmarks2"}
   -- tell redList to make new reminder at end with properties {name:"Test", body:"Call Bob this time"}
end tell

NOTE: Reminder.app has 60 standard emblems. Each of them has standard name. I showed you 9 of them. Reminder.app understand only numerical colours. It has not colour constants Red, Green an so on.

Last edited by KniazidisR (2020-04-26 12:50:28 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#3 2020-04-26 11:24:18 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Catalina Reminders, make new list with color? emblem?

As far as I know, at least under High Sierra, the words color and emblem don't appear in the resources files of Reminders.
Only three properties for a list : name, id and container.

Under Catalina, I know that the resources contain the localized strings for "Change color" and Change badge". Maybe it's badge which is the correct name of the property to set.
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.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 26 avril 2020 19:23:43

Offline

 

#4 2020-04-26 11:58:42 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Catalina Reminders, make new list with color? emblem?

Yvan,

The code I provided above works. Without any GUI scripting.


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#5 2020-04-26 01:14:08 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Catalina Reminders, make new list with color? emblem?

@KniazidisR

I carefully wrote:

If they aren't, I fear that you will have to rely upon GUI scripting to do what you want.

As you wrote that the instruction

Applescript:

set redList to make new list with properties {name:"Red List", color:colorsRecord's Red, emblem:"bookmarks2"}

does its job, I assume that the properties color and emblem are defined in the dictionary.

When searching in the resources of the app I found only "emblem" as a substring of "Alterar emblema" which is the localized string for "Change badge" and in "Emblema de %@" which is the localized string for "%@ badge" in the two variants of Portuguese.

Maybe it was a bad idea to search in the localized resources because the sdefs aren't localized.
Searching in the sdef I found :
</property>
<property name="color" code="colr" type="text" description="The color of the list">
<cocoa key="color" />
</property>
<property name="emblem" code="iimg" type="text" description="The emblem icon name of the list">
<cocoa key="emblem" />
</property>

You may find the labels of emblems in the file :
Reminders.app:Contents:Resources:en.lproj:Localizable.string
but it's may be easier to grab them from the menu : Change Badge

The list of color names is available in:
System:Library:Colors:Crayons.clr:English.lproj:Crayons.strings
MAYBE it's en.lproj in Catalina

I just hope for you that there is no need to use their localized spelling.

Applescript:

set theBundle to ((path to library folder from system domain as string) & "Colors:Crayons.clr") as «class furl»
set x to "Mercury"
set loc to localized string x from table "Crayons" in bundle theBundle -- so that there is a single instruction, possibly in a handler
set marron_loc to loc

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) dimanche 26 avril 2020 21:13:09

Offline

 

#6 2020-04-26 02:03:32 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Catalina Reminders, make new list with color? emblem?

Yvan,

Before you localize the code, you need to have a working version of the English code. And, I don’t see any “Change badge” menu on Catalina. I got the code in a completely different way. I can list all 60 emblems built into Reminders.app. But I'm too lazy... As for the color, when I see red doesn't work, "red" doesn't work, "Red" doesn't work, than I guess that Reminders.app doesn't use standard color names at all...

And I'm not in vain using the English version of OS. With it, everything is easier to program than in my 2 native languages. I consider it logical for the Americans to leave good software production, the Russians for the production of vodka, and the Greeks for the production of Metaxa. To the French like you, I would leave the primacy in fashion, and in general in the attributes of appearance... smile And the British are the smartest nation. It is better to be friends with them... smile I am Russian, Greek, Soviet, Georgian... only not British sad What a pity... Even with coronavirus, they did not begin to fool their people. They were the first to tell the truth - we all have to get a new disease in order for humanity to gain immunity.

Last edited by KniazidisR (2020-04-26 02:36:01 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#7 2020-04-26 07:31:44 pm

johncatalano
Member
Registered: 2014-03-07
Posts: 26

Re: Catalina Reminders, make new list with color? emblem?

Thank you both, gentlemen.

@KniazidisR - Your code worked just fine for me. Thank you. Where are you able to find the names of all of the emblems?

Offline

 

#8 2020-04-26 09:56:08 pm

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Catalina Reminders, make new list with color? emblem?

johncatalano wrote:

Where are you able to find the names of all of the emblems?


I just guessed asking the Reminder application itself to tell me the names of its emblems.

The secret: manually create some reminders in the Reminder.app, open Get Info right-clicking on the reminder, set manually what emblem you want. You can set 60 reminders, each with different emblem.

Then run script:

Applescript:


-- tell me, please your secrets...
tell application "Reminders" to get emblem of container of every reminder

Or, you can set different emblem for 1 same reminder and run the script 60 times to get names of emblems one by one. T-ss, do not reveal our secret to other sites  lol

See here the built-in emblems:

34k8C.png

Last edited by KniazidisR (2020-04-26 10:21:51 pm)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#9 2020-04-27 03:36:45 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Catalina Reminders, make new list with color? emblem?

@KniazidisR

I never start from the app English version for the simple reason that I never ran my system in English.

I am able to get the localized strings for every language available because I have a set of resources containing those of three OSes: High Sierra, Mojave and Catalina.

Here is an example:

Applescript:

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

-- Build an array of the localized names of the application Reminders
-- Yvan KOENIG (VALLAURIS, France) dimanche 27 avril 2020
----------------------------------------------------------------

property |⌘| : a reference to current application

set theLanguages to paragraphs of "ar
ca
cs
da
de
el
en_AU
en_GB
en
es_419
es
fi
fr_CA
fr
he
hi
hr
hu
id
it
ja
ko
ms
nl
no
pl
pt_PT
pt
ro
ru
sk
sv
th
tr
uk
vi
zh_CN
zh_HK
zh_TW"


set root to (path to application "Reminders" as text) & "Contents:Resources:"
-- set root to "resources YK:resources trois:Catalina:Applications:Reminders.app:Contents:Resources:"
set fullTable to "Localizable.strings"

set {key1, key2} to {"Change Badge", "Change Color"}
set allLocales to {"language" & tab & key1 & tab & key2}
-- Now extract the values for every language available
repeat with usedLanguage in theLanguages
   set anURL to (|⌘|'s NSURL's fileURLWithPath:(POSIX path of (root & usedLanguage & ".lproj:" & fullTable)))
   set theDict to (|⌘|'s NSDictionary's dictionaryWithContentsOfURL:anURL)
   if theDict is not missing value then
       set val1 to (theDict's valueForKey:key1)
       set val2 to (theDict's valueForKey:key2)
   else
       set {val1, val2} to {"??", "??"}
   end if
   set end of allLocales to (usedLanguage as string) & tab & val1 & tab & val2
end repeat

set theData to my concatlist:allLocales usingString:linefeed
-- save data to new file
set reportName to "Reminders locales.txt"
set hfsPath to (path to desktop 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

#=====

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:

#=====

Applied upon Catalina, it return:
language    Change Badge    Change Color
ar    تغيير الشارة    تغيير اللون
ca    Canviar distintiu    Canviar el color
cs    Změnit odznak    Změnit barvu
da    Skift mærke    Skift farve
de    Badge ändern    Farbe ändern
el    Αλλαγή ταμπέλας    Αλλαγή χρώματος
en_AU    Change Badge    Change Colour
en_GB    Change Badge    Change Colour
en    Change Badge    Change Color
es_419    Distintivo de cambio    Cambiar color
es    Cambiar indicador    Cambiar color
fi    Muuta merkkiä    Vaihda väri
fr_CA    Changer de pastille    Modifier la couleur
fr    Modifier le badge    Modifier la couleur
he    שינוי תגית    שנה את הצבע
hi    बैज बदलना    रंग बदलें
hr    Promijeni bedž    Promijeni boju
hu    Jelvény módosítása    Szín módosítása
id    Ubah Tanda    Ubah Warna
it    Modifica badge    Modifica colore
ja    バッジを変更    カラーを変更
ko    배지 변경    색상 변경
ms    Tukar Lencana    Tukar Warna
nl    Wijzig badge    Wijzig kleur
no    Bytt merke    Endre farge
pl    Zmień plakietkę    Zmień kolor
pt_PT    Alterar emblema    Alterar a cor
pt    Alterar Emblema    Alterar Cor
ro    Schimbă insigna    Schimbă culoare
ru    Изменить значок    Изменить цвет
sk    Zmeniť odznak    Zmeniť farbu
sv    Ändra bricka    Ändra färg
th    เปลี่ยนป้ายประกาศ    เปลี่ยนสี
tr    İşareti Değiştir    Rengi Değiştir
uk    Змінити значок    Змінити колір
vi    Thay đổi biểu tượng    Thay đổi Màu
zh_CN    更改标记    更改颜色
zh_HK    更改標記    更改顏色
zh_TW    更改標記    更改顏色

Other example:

Applescript:

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

-- Build an array of the localized strings used by the application Finder
-- Some languages are defined twice because they aren't named the same according to the running OS
-- Yvan KOENIG (VALLAURIS, France) dimanche 29 mars 2020 17:42:48
----------------------------------------------------------------

property |⌘| : a reference to current application

set theLanguages to paragraphs of "ar
ca
cs
da
de
el
en_AU
en_GB
en
es_419
es
fi
fr_CA
fr
he
hi
hr
hu
id
it
ja
ko
ms
nl
no
pl
pt_PT
pt
ro
ru
sk
sv
th
tr
uk
vi
zh_CN
zh_HK
zh_TW
Dutch
English
French
German
Italian
Japanese
Spanish"


set root to (path to application "Finder" as text) & "Contents:Resources:"
--set root to "resources YK:resources trois:Catalina:System:Library:CoreServices:Finder.app:" & "Contents:Resources:"
set fullTable to "ArrangeByMenu.strings"
set {key1, key2} to {"115.title", "116.title"}
set allLocales to {"language" & tab & key1 & tab & key2}
-- Now extract the values for every language available
repeat with usedLanguage in theLanguages
   set anURL to (|⌘|'s NSURL's fileURLWithPath:(POSIX path of (root & usedLanguage & ".lproj:" & fullTable)))
   set theDict to (|⌘|'s NSDictionary's dictionaryWithContentsOfURL:anURL)
   if theDict is not missing value then
       set val1 to (theDict's valueForKey:key1)
       set val2 to (theDict's valueForKey:key2)
   else
       set {val1, val2} to {"??", "??"}
   end if
   set end of allLocales to (usedLanguage as string) & tab & val1 & tab & val2
end repeat

set theData to my concatlist:allLocales usingString:linefeed
-- save data to new file
set reportName to "Finder local name.txt"
set hfsPath to (path to desktop 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

#=====

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:

#=====

Applied on my running system, it return:
language    115.title    116.title
ar    تاريخ الإضافة    تاريخ آخر فتح
ca    Data d’addició    Data de la darrera obertura
cs    Data přidání    Data posledního otevření
da    Tilføjet den    Sidst åbnet
de    ??    ??
el    Ημερομηνία προσθήκης    Πιο πρόσφατο άνοιγμα
en_AU    ??    ??
en_GB    ??    ??
en    ??    ??
es_419    Fecha en que se agregó    Fecha de la última apertura
es    ??    ??
fi    Lisätty    Avattu viimeksi
fr_CA    ??    ??
fr    ??    ??
he    תאריך הוספה    תאריך פתיחה אחרון
hi    जोड़ने की तिथि    अंतिम बार खोलने की तिथि
hr    Datum dodavanja    Datum zadnjeg otvaranja
hu    Utolsó hozzáadás dátuma    Utolsó megnyitás dátuma
id    Tanggal Ditambahkan    Tanggal Terakhir Dibuka
it    ??    ??
ja    ??    ??
ko    추가일    최근 사용일
ms    Tarikh Ditambah    Tarikh Terakhir Dibuka
nl    ??    ??
no    Dato lagt til    Dato sist åpnet
pl    Data dołączenia    Data ostatniego otwarcia
pt_PT    Data de adição    Data da última abertura
pt    Data da Adição    Data da Última Abertura
ro    Data adăugării    Data ultimei deschideri
ru    по дате добавления    по дате последнего открытия
sk    Dátum pridania    Naposledy otvorené
sv    Tilläggsdatum    Senast öppnad
th    วันที่เพิ่ม    วันที่เปิดครั้งล่าสุด
tr    Ekleniş Tarihi    Son Açılış Tarihi
uk    датою додавання    датою останнього відкривання
vi    Ngày thêm    Ngày mở cuối cùng
zh_CN    添加日期    上次打开日期
zh_HK    ??    ??
zh_TW    加入日期    上次打開日期
Dutch    Toevoegingsdatum    Openingsdatum
English    ??    ??
French    Date de l’ajout    Date de dernière ouverture
German    Hinzugefügt am    Zuletzt geöffnet
Italian    Data di aggiunta    Data ultima apertura
Japanese    追加日    最後に開いた日
Spanish    Fecha de inclusión    Fecha de la última apertura

If I apply to my full set of resources to get the Catalina's strings I get:
language    115.title    116.title
ar    تاريخ الإضافة    تاريخ آخر فتح
ca    Data d’addició    Data de la darrera obertura
cs    Data přidání    Data posledního otevření
da    Tilføjelsesdato    Sidst åbnet
de    Hinzugefügt am    Zuletzt geöffnet
el    Ημερομηνία προσθήκης    Πιο πρόσφατο άνοιγμα
en_AU    Date Added    Date Last Opened
en_GB    Date Added    Date Last Opened
en    ??    ??
es_419    Fecha en que se agregó    Fecha de la última apertura
es    Fecha de inclusión    Fecha de la última apertura
fi    Lisätty    Avattu viimeksi
fr_CA    Date de l’ajout    Date de dernière ouverture
fr    Date de l’ajout    Date de dernière ouverture
he    תאריך הוספה    תאריך פתיחה אחרון
hi    जोड़ने की तिथि    अंतिम बार खोलने की तिथि
hr    Datum dodavanja    Datum zadnjeg otvaranja
hu    Hozzáadás dátuma    Utolsó megnyitás dátuma
id    Tanggal Ditambahkan    Tanggal Terakhir Dibuka
it    Data di aggiunta    Data ultima apertura
ja    追加日    最後に開いた日
ko    추가된 날짜    최근 사용일
ms    Tarikh Ditambah    Tarikh Terakhir Dibuka
nl    Toevoegingsdatum    Openingsdatum
no    Dato lagt til    Dato sist åpnet
pl    Data dołączenia    Data ostatniego otwarcia
pt_PT    Data de adição    Data da última abertura
pt    Data da Adição    Data da Última Abertura
ro    Data adăugării    Data ultimei deschideri
ru    по дате добавления    по дате последнего открытия
sk    Dátum pridania    Naposledy otvorené
sv    Tilläggsdatum    Senast öppnad
th    วันที่เพิ่ม    วันที่เปิดครั้งล่าสุด
tr    Ekleniş Tarihi    Son Açılış Tarihi
uk    Дата додавання    Дата останнього відкривання
vi    Ngày thêm    Ngày mở cuối cùng
zh_CN    添加日期    上次打开日期
zh_HK    加入日期    上次開啟日期
zh_TW    加入日期    上次打開日期
Dutch    ??    ??
English    ??    ??
French    ??    ??
German    ??    ??
Italian    ??    ??
Japanese    ??    ??
Spanish    ??    ??

As you see, the English strings aren't reachable.
Happily, I may grab them from en_AU or en_GB.

On my side I make quite no judgment upon languages.
I think that they are all valuable and hope that none of them will disappear.
I have a unique rule about that: always use French with applications able to work with it and use English only when an application is unable to work with French.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 27 avril 2020 11:36:37

Offline

 

#10 2020-04-27 05:49:21 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Catalina Reminders, make new list with color? emblem?

johncatalano wrote:

Thank you both, gentlemen.

@KniazidisR - Your code worked just fine for me. Thank you. Where are you able to find the names of all of the emblems?




If I was able to run Catalina I would write a script extracting the name of the emblems from the pane reproduced in KniazidisR's answer.

As I can't do that I post here a script returning the entire set of localizable strings used in the GUI interface of Reminders.
Several of them are the names of emblems.

Applescript:

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

-- Build an array of the localized strings used by Reminders
-- Yvan KOENIG (VALLAURIS, France) Lundi 27 avril 2020
----------------------------------------------------------------
property openInNumbers : true
-- true --> replace embedded linefeeds by the string "⁋" and open the report with Numbers
-- false --> keep the embedded linefeeds and open the report with TextEdit

property |⌘| : a reference to current application

set theLanguages to paragraphs of "ar
ca
cs
da
de
el
en_AU
en_GB
en
es_419
es
fi
fr_CA
fr
he
hi
hr
hu
id
it
ja
ko
ms
nl
no
pl
pt_PT
pt
ro
ru
sk
sv
th
tr
uk
vi
zh_CN
zh_HK
zh_TW"

tell application "Finder" to set forYK to exists folder "resources YK"
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"

-- Extract the keys from the English resource
set theFile to root & "en.lproj:" & fullTable
set anURL to |⌘|'s NSURL's fileURLWithPath:(POSIX path of theFile)
set theDict to (|⌘|'s class "NSDictionary"'s dictionaryWithContentsOfURL:anURL)
set theKeys to theDict's allKeys()
set cntRows to 1 + (count theKeys)
set allLists to {{"allKeys"} & theKeys as list}

-- Now extract the values for every language available
repeat with usedLanguage in theLanguages
   set aList to {usedLanguage as string} -- insert the language prefix as header
   set theFile to root & usedLanguage & ".lproj:" & fullTable
   set anURL to (|⌘|'s NSURL's fileURLWithPath:(POSIX path of theFile))
   set theDict to (|⌘|'s class "NSDictionary"'s dictionaryWithContentsOfURL:anURL)
   if theDict is not missing value then
       set theValues to theDict's allValues()
   else
       set theValues to "empty" -- empty dictionary-- Not used here
   end if
   set aList to aList & theValues as list
   set end of allLists to aList
end repeat

-- Build the final array
set bigArray to |⌘|'s NSMutableArray's new()
repeat with i from 1 to cntRows
   
   set smallArray to |⌘|'s NSMutableArray's new()
   repeat with j from 1 to count allLists
       set aString to (item i of item j of allLists) as text
       if openInNumbers then
           if aString contains linefeed then set aString to ((|⌘|'s NSArray's arrayWithArray:(paragraphs of aString))'s componentsJoinedByString:"⁋") as text
       end if
       (smallArray's addObject:aString)
   end repeat
   
   (bigArray's addObject:((smallArray's componentsJoinedByString:tab) as string))
end repeat

set theData to (bigArray's componentsJoinedByString:linefeed)

-- save data to new file
set bareName to "Reminders locales"
set hfsPath to (path to desktop as text) & bareName & ".txt"
set targetFile to hfsPath as «class furl»
(theData's writeToURL:targetFile atomically:true encoding:(|⌘|'s NSUTF8StringEncoding) |error|:(missing value))

if openInNumbers then
   tell application "Numbers"
       activate
       if exists window bareName then close window bareName
       open targetFile
   end tell
else
   set wName to bareName & ".txt"
   tell application "TextEdit"
       activate
       if exists window wName then close window wName
       open targetFile
   end tell
end if
#=====

Of course, it may be used for other applications and other tables.
I already used it to get the name of the shapes used by Numbers.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 27 avril 2020 13:49:13

Offline

 

#11 2020-04-27 12:57:18 pm

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Catalina Reminders, make new list with color? emblem?

Here is a quick and dirty script building a list of the localized names of the 48 pencils available in the choose color window with their hexadecimal value.
It uses a tool defined at system level so the fact that I drive it under Numbers doesn't matter.
Doing that is just fine for me because I know very well the way to activate it.


Applescript:

----------------------------------------------------------------
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.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}
           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
                   click radio button i
               end tell
           end tell -- splitter group 1
           tell toolbar 1 to click button -1 -- RCWeb
           tell splitter group 1
               -- class of UI elements --> {group, slider, static text, text field, splitter, color well, checkbox, scroll area}
               tell group 1
                   -- class of UI elements --> {text field, list, static text, static text, static text, checkbox, text field, text field, text field, static text}
                   -- value of text fields --> {"000000", "00", "00", "00"}
                   set RGB to value of text field 1
               end tell
           end tell -- splitter group 1
       end tell -- floating window
       set end of descriptors to itsName & tab & "#" & RGB
   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:

#=====

As always, I disabled numerous instructions used to build the code which are useless when the building is achieved.
I don't remove them because they are useful when I return on a script months after creating it.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) lundi 27 avril 2020 20:57:11

Offline

 

#12 2020-04-28 04:15:53 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Catalina Reminders, make new list with color? emblem?

Hello

Would one of you be fair enough to open Reminders, reveal a palette like the one appearing in message #14 then run the script listed below and send me the complete log history.
With this data I would prepare a script designed to extract the names of the emblems.

You may attach the history in a mail sent to [koenigyvan[at]mac[dot]com].

Applescript:

set theProcess to "Reminders"
tell application theProcess to activate

tell application "System Events" to tell process theProcess
   set frontmost to true
   subrole of every window --> {"AXFloatingWindow", "AXStandardWindow"}
   set mainWindow to first window whose subrole is "AXStandardWindow"
   
   tell mainWindow --> window "Sans titre"
       its properties
       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}
       position of UI elements --> {{594, 149}, {594, 121}, {641, 121}, {1583, 122}, {1606, 122}, {594, 1088}, {1584, 1092}, {1607, 1092}, {1584, 121}, {1584, 149}, {601, 33}, {641, 33}, {621, 33}, {1241, 32}, {594, 52}, {594, 97}, {1223, 32}, {1161, 32}}
       size of UI elements --> {{989, 938}, {47, 27}, {942, 28}, {23, 25}, {23, 25}, {989, 34}, {23, 25}, {23, 25}, {270, 28}, {270, 938}, {14, 16}, {14, 16}, {14, 16}, {59, 17}, {1260, 45}, {1260, 23}, {17, 17}, {62, 17}}
   end tell -- mainWindow
   try
       set floatingWindow to first window whose subrole is "AXFloatingWindow"
       tell floatingWindow --> window "Remplissage couleur"
           its properties
           class of UI elements --> {splitter group, button, button, button, toolbar, static text}
           position of UI elements --> {{1620, 463}, {1625, 413}, {1661, 413}, {1643, 413}, {1620, 428}, {1679, 413}}
           size of UI elements --> {{228, 376}, {13, 14}, {13, 14}, {13, 14}, {228, 35}, {113, 14}}
           try
               subrole of every button --> {"AXCloseButton", "AXZoomButton", "AXMinimizeButton"}
           end try
           try
               value of every static text --> {"Remplissage couleur"}
           end try
           try
               tell toolbar 1
                   its properties
                   class of UI elements --> {button, button, button, button, button, button}
                   description of every button --> {"Roue des couleurs", "Curseurs de couleur", "Palettes de couleurs", "Palettes d’images", "Crayons", "RCWeb"}
               end tell -- toolbar 1
           end try
           try
               tell splitter group 1
                   its properties
                   class of UI elements --> {static text, radio group, slider, static text, text field, splitter, color well, checkbox, scroll area}
                   try
                       value of every static text --> {"", "Opacité"}
                   end try
                   try
                       name of every text field --> "Opacité"
                       name of every text field --> "100 %"
                   end try
                   try
                       description of every checkbox
                   end try
                   try
                       repeat with aGroup in every group
                           tell aGroup
                               its properties
                               class of UI elements -->
                           end tell -- group
                       end repeat
                   end try
                   try
                       repeat with aSlider in every slider
                           tell aSlider
                               its properties
                               its name --> "Opacité"
                               class of UI elements --> {value indicator}
                           end tell -- slider
                       end repeat
                   end try
                   try
                       repeat with aSplitter in every splitter
                           tell aSplitter
                               its properties
                               class of UI elements --> {}
                           end tell -- splitter
                       end repeat
                   end try
                   try
                       repeat with aColorWell in every color well
                           tell aColorWell
                               its properties
                               class of UI elements --> {}
                           end tell -- aColorWell
                       end repeat
                   end try
                   try
                       repeat with aScrollArea in every scroll area
                           tell aScrollArea
                               its properties
                               class of UI elements
                               --> 1 --> {table, scroll bar}
                               --> 2 --> {list, scroll bar}
                               try
                                   repeat with aTable in every table
                                       tell aTable
                                           its properties
                                           class of UI elements
                                       end tell -- aTable
                                   end repeat
                               end try
                               try
                                   repeat with aScrollBar in every scroll bar
                                       tell aScrollBar
                                           its properties --> "AXVerticalOrientation"
                                           class of UI elements --> {}
                                       end tell -- aScrollBar
                                   end repeat
                               end try
                               try
                                   repeat with aList in every list
                                       tell aList
                                           its properties --> "Échantillons favoris"
                                           class of UI elements --> {}
                                       end tell -- aList
                                   end repeat
                               end try
                           end tell -- scroll area
                       end repeat
                   end try
               end tell -- splitter group 1
           end try
       end tell -- floatingWindow
   end try
end tell

The results appearing in the script above are those which I got upon Numbers.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 28 avril 2020 12:14:16

Offline

 

#13 2020-04-28 07:52:12 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6395

Re: Catalina Reminders, make new list with color? emblem?

Yvan,

The palette is a pop over, so pop over 1 of button 3 of sheet 1 of mainWindow

Last edited by Shane Stanley (2020-04-28 07:54:01 am)


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Online

 

#14 2020-04-28 08:24:59 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Catalina Reminders, make new list with color? emblem?

Using GUI scripting you can get emblem names list only clumsy way, since the images don't have names but only descriptions and helps related to correct name. The names or values of 12 built-in colours using GUI scripting you can't get at all.

If you open Reminders window as showed on my picture above, here is how to get emblem names using GUI scripting (Catalina):

Applescript:


tell application "System Events" to tell application process "Reminders"
   tell window "Reminders" to tell sheet 1 to tell UI element 7
       -- get emblem names using GUI scripting
       set emblemNames to {}
       repeat with i from 1 to (count every UI element of UI element 2 of UI element 2)
           set aDescription to description of image 1 of UI element i of UI element 2 of UI element 2
           set end of emblemNames to text 10 thru -1 of aDescription
       end repeat
       -- set u to UI element 4 of UI element 1 of UI element 2 -- Green color button, useless
   end tell
end tell
return emblemNames

NOTE: you can get 12 built-in colours the same way as I got emblems "manually", without GUI scripting. Create manually 12 reminders with 12 built-in colours. It should be real reminder and not empty. Then run this:

Applescript:


-- tell me, please your secrets...
tell application "Reminders" to get color of container of every reminder

NOTE 2: In the GUI interface the colours has descriptions like "Green" or "Selected, Green".

12 built-in colours:

Applescript:


"#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

Last edited by KniazidisR (2020-04-28 09:42:19 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#15 2020-04-28 09:22:32 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Catalina Reminders, make new list with color? emblem?

KniazidisR wrote:

Using GUI scripting you can get emblem names list only clumsy way, since the images don't have names but only descriptions and helps related to correct name. The names or values of 12 built-in colours using GUI scripting you can't get at all.

If you open Reminders window as showed on my picture above, here is how to get emblem names using GUI scripting (Catalina):

Applescript:


tell application "System Events" to tell application process "Reminders"
   tell window "Reminders" to tell sheet 1 to tell UI element 7
       -- get emblem names using GUI scripting
       set emblemNames to {}
       repeat with i from 1 to (count every UI element of UI element 2 of UI element 2)
           set aDescription to description of image 1 of UI element i of UI element 2 of UI element 2
           set end of emblemNames to text 10 thru -1 of aDescription
       end repeat
       -- set u to UI element 4 of UI element 1 of UI element 2 -- Green color button, useless
   end tell
end tell
return emblemNames

NOTE: you can get 12 built-in colours the same way as I got emblems "manually", without GUI scripting. Create manually 12 reminders with 12 built-in colours. Then run this:

Applescript:


-- tell me, please your secrets...
tell application "Reminders" to get color of container of every reminder

NOTE 2: In the GUI interface the colours has descriptions like "Green" or "Selected, Green".



What is clumsy in the fact that we must ask for description, not for name ?
Description is a property of the UI element as well as its title or its name…
The  only difference is that, as I work upon localized items for years I'm aware of the need to rely upon description for years too.
I know also that some properties are localized when others aren't. It's a well known feature (at least for me) for the Finder.

You are funny, but you forget that I can't run the new Reminders application which requires Catalina.
If I was able to do that the questions would be answered since several hours.

Must I understand that the GUI of Reminders doesn't proposed us to use the "palette" of Crayons" ?
Strings like "Selected, Green" aren't available in localizable resources. I guess that what you see is the concatenation of three substrings : "Selected", ", " and "Green"

Oops, I forgot to say that after working more than 30 years as a potter I dislike to work with my hands when a computer is able to achieve what I want to get.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 28 avril 2020 17:03:27

Offline

 

#16 2020-04-28 10:51:45 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Catalina Reminders, make new list with color? emblem?

Bingo.

My grand daughter arrived here so I may enter her macBook running Catalina.

Here is the result.

Of course I got French names.

Applescript:

tell application "System Events" to tell process "Reminders"
   set frontmost to true
   tell window 1
       class of UI elements --> {splitter group, button, button, button, sheet}
       tell sheet 1
           class of UI elements --> {static text, static text, group, text field, button, button, button}
           description of buttons --> {"bouton", "bouton", "pastille Liste, Personnalisé"}
           tell button -1
               class of UI elements --> {image, pop over}
               tell pop over 1
                   class of UI elements --> {UI element, UI element}
                   
                   tell UI element 1
                       class of UI elements --> --> {button, button, button, button, button, button, button, button, button, button, button, button}
                       set theColors to description of buttons --> {"Rouge", "Orange", "Jaune", "Vert", "Bleu clair", "Bleu", "Indigo", "Rose", "Violet", "Marron", "Gris", "Rose"}
                       --name of attributes of button 6
                       --value of attributes of button 6
                   end tell
                   
                   tell UI element 2
                       class of UI elements --> -> {button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button}
                       set theEmblems to description of buttons --> {"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"}
                       
                   end tell
                   
               end tell
           end tell
       end tell
   end tell
end tell

return {theColors, linefeed, linefeed, theEmblems}

These strings are defined in the files :
"Applications:Reminders.app:Contents:Resources:<yourLanguage>.lproj:Localizable.strings"

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 28 avril 2020 18:51:15

Offline

 

#17 2020-04-29 02:57:18 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Catalina Reminders, make new list with color? emblem?

As I have no longer access to Catalina, I can't test this enhanced version supposed to return more infos.
For each color it would return its hex descriptor.

Applescript:

tell application "System Events" to tell process "Reminders"
   set frontmost to true
   tell window 1
       class of UI elements --> {splitter group, button, button, button, sheet}
       tell sheet 1
           class of UI elements --> {static text, static text, group, text field, button, button, button}
           description of buttons --> {"bouton", "bouton", "pastille Liste, Personnalisé"}
           tell button -1
               class of UI elements --> {image, pop over}
               tell pop over 1
                   class of UI elements --> {UI element, UI element}
                   
                   tell UI element 1
                       class of UI elements --> --> {button, button, button, button, button, button, button, button, button, button, button, button}
                       --    set theColors to description of buttons --> {"Rouge", "Orange", "Jaune", "Vert", "Bleu clair", "Bleu", "Indigo", "Rose", "Violet", "Marron", "Gris", "Rose"}
                       set theColors to {}
                       repeat with aButton in theButtons
                           tell aButton
                               set {{x, y}, {w, h}} to {position, size}
                               tell me to set colorDesc to do shell script "/usr/local/bin/cliclick cp:" & x + w div 2 & "," & y + h div 2
                               set RGB to "#"
                               repeat with str in my decoupe(theColors, space)
                                   set RGB to RGB & my num2hex(str as integer)
                               end repeat
                               set end of theColors to {its description, RGB}
                           end tell -- aButton
                       end repeat
                       --name of attributes of button 6
                       --value of attributes of button 6
                   end tell
                   
                   tell UI element 2
                       class of UI elements --> -> {button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button, button}
                       set theEmblems to description of buttons --> {"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"}
                       
                   end tell
                   
               end tell
           end tell
       end tell
   end tell
end tell

return {theColors, linefeed, linefeed, theEmblems}

#=====

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(int)
   set hi to int div 16
   set lo to int mod 16
   return (text item (hi + 1) of "0123456789ABCDEF") & (text item (lo + 1) of "0123456789ABCDEF")
end num2hex

#=====

I confirm that the string "Selected, Green" is just the concatenation of "Selected", ", " and "Green". In fact the last string is the name of the selected color.

<key>Selected</key>
    <string>Sélectionnée</string>
<key>Red</key>
    <string>Rouge</string>
<key>Orange</key>
    <string>Orange</string>
<key>Yellow</key>
    <string>Jaune</string>
<key>Green</key>
    <string>Vert</string>
<key>Light Blue</key>
    <string>Bleu clair</string>
<key>Blue</key>
    <string>Bleu</string>
<key>Indigo</key>
    <string>Indigo</string>
<key>Rose</key>
    <string>Rose</string>

<key>Purple</key>
    <string>Violet</string>
<key>Brown</key>
    <string>Marron</string>
<key>Gray</key>
    <string>Gris</string>
<key>Pink</key>
    <string>Rose</string>
  -- would be better with "Rose clair"

As you may see, there is an oddity in the localization both strings "Rose" and "Pink" are translated by "Rose" which is annoying.
Maybe somebody would be fair enough to file a bug report.

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 29 avril 2020 10:31:18

Last edited by Yvan Koenig (2020-04-29 02:59:23 am)

Offline

 

#18 2020-04-29 03:38:15 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Catalina Reminders, make new list with color? emblem?

CAUTION

I just discover an oddity.
The values returned by do shell script "/usr/local/bin/cliclick cp:" & x + w div 2 & "," & y + h div 2
don't match the values given by Apple.
I applied both schemes upon the palette of crayons and here is what I got:

ColorName    Cliclick    Apple
Réglisse    #000000    #000000
Plomb    #212121    #181818
Tungstène    #424242    #323232
Fer    #5F5E5F    #4C4C4B
Acier    #797979    #666666
Étain    #919191    #7F7F7E
Nickel    #929292    #807F7F
Aluminium    #A9A9A9    #999998
Magnésium    #C0C0C0    #B3B3B2
Argent    #D6D6D6    #CCCCCB
Mercure    #EBEBEB    #E6E6E5
Neige    #FFFFFF    #FEFEFE
Cayenne    #92130B    #7F0002
Moka    #925211    #7F3F02
Asperge    #928F1B    #7F7F03
Fougère    #518E17    #3F7F02
Trèfle    #128D15    #107F01
Mousse    #138E53    #107F40
Sarcelle    #159192    #107F80
Océan    #0A5591    #073F80
Minuit    #052090    #00007F
Aubergine    #522290    #40007F
Prune    #932891    #800080
Bordeaux    #921B51    #80003F
Marasquin    #FC2A1C    #FB0106
Mandarine    #FD9326    #FC8008
Citron    #FEF937    #FEFE0A
Citron vert    #91F730    #7FFE07
Printemps    #28F72D    #21FE06
Écume    #29F896    #21FE80
Turquoise    #2CFCFE    #20FEFE
Aqua    #1A99FC    #0F7FFE
Myrtille    #103FFB    #0000FE
Raisin    #9443FB    #8000FE
Magenta    #FD4CFC    #FB02FE
Fraise    #FC3692    #FB027F
Saumon    #FD7F7C    #FC6665
Cantaloup    #FED37F    #FDCC65
Banane    #FFFA81    #FFFF66
Miellée    #D5FA80    #CCFF66
Flore    #78F87F    #66FF66
Embruns    #79FBD6    #66FFCB
Glace    #79FDFE    #66FFFE
Ciel    #7AD6FD    #66CCFE
Orchidée    #7B84FC    #6666FE
Lavande    #D687FC    #CC66FE
Chewing gum    #FD89FD    #FC66FE
Œillet    #FD8DD7    #FC6FCE

Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mercredi 29 avril 2020 11:38:07

Last edited by Yvan Koenig (2020-04-29 03:39:12 am)

Offline

 

#19 2020-04-29 04:54:58 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Catalina Reminders, make new list with color? emblem?

Yvan Koenig wrote:

I just discover an oddity.
The values returned by do shell script "/usr/local/bin/cliclick cp:" & x + w div 2 & "," & y + h div 2
don't match the values given by Apple.


I don’t understand what you need. When you create your application, you can also give your own definitions of colours. For example, I can name the color #000000 (usually, "Black") - "White", and no one will fine me for that. What do you dislike about the color definitions defined by Numbers? There is nothing criminal in this.

They are fixed number, the exact values I have already listed to you. Regarding the extraction of emblems, I can agree with GUI scripting, since the user can add some custom emblems. But with colours? With them, you just need to specify a record with 12 items. Moreover, the color names in this application are completely useless. Precisely because the developers of Numbers.app were too lazy to create such a record {color name: value...} themselves. Well, they were too lazy - that means I create the definition myself.

Last edited by KniazidisR (2020-04-29 05:35:00 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#20 2020-04-29 06:55:44 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 6395

Re: Catalina Reminders, make new list with color? emblem?

Yvan Koenig wrote:

The values returned by do shell script "/usr/local/bin/cliclick cp:" & x + w div 2 & "," & y + h div 2
don't match the values given by Apple.



That will be due to differing color spaces.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Online

 

#21 2020-04-29 07:17:56 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: 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.

Applescript:

----------------------------------------------------------------
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

Offline

 

#22 2020-04-29 07:34:46 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Catalina Reminders, make new list with color? emblem?

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.

Last edited by KniazidisR (2020-04-29 07:55:38 am)


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#23 2020-04-29 07:55:08 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Catalina Reminders, make new list with color? emblem?

Shane Stanley wrote:
Yvan Koenig wrote:

The values returned by do shell script "/usr/local/bin/cliclick cp:" & x + w div 2 & "," & y + h div 2
don't match the values given by Apple.



That will be due to differing color spaces.




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

Offline

 

#24 2020-04-29 08:06:29 am

KniazidisR
Member
Registered: 2019-03-03
Posts: 1259

Re: Catalina Reminders, make new list with color? emblem?

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.


Model: MacBook Pro
OS X: Catalina 10.15.4
Web Browser: Safari 13.1
Ram: 4 GB

Offline

 

#25 2020-04-29 08:19:38 am

Yvan Koenig
Member
Registered: 2006-09-14
Posts: 4533

Re: Catalina Reminders, make new list with color? emblem?

KniazidisR wrote:

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.



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.

Shane Stanley wrote:

Yvan,

The palette is a pop over, so pop over 1 of button 3 of sheet 1 of mainWindow



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

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)