Would be useful to know which OS is active on your side.
Below is my script in which I re-enabled every instructions which were disabled because they aren’t useful to do the job.
They just give informations upon the UI elements available.
I just added one instruction
-- use the free CLI : cliclick
-- Yvan KOENIG (VALLAURIS, France) jeudi 4 juin 2020 15:58:04
my Germaine()
on Germaine()
tell application "Mail"
set quoteLevel_loc to localized string "QuoteLevel" from table "Compose"
set decreaseQuoteLevel_loc to localized string "DecreaseQuoteLevel" from table "Compose"
set format_loc to localized string "ToolbarComposeFormatBar"
set _sel to selection
end tell -- Mail
set myAnswer to "Thank you." & return & "The text gets inserted into the first line in the Mail reply message, but the signature and quoted text are deleted." & return & "Is there a way to create a reply message, maintain the signature and quoted text, while inserting next text above it?"
repeat with _msg in _sel
tell application "Mail" to tell _msg
set replyMessage to reply
end tell
tell application "System Events" to tell process "Mail"
set frontmost to true
tell window 1
class of UI elements --> {static text, text field, button, static text, text field, button, static text, text field, button, static text, text field, button, static text, text field, scroll area, pop up button, static text, button, button, button, toolbar, group}
set nbElements to count UI elements --> 22 -- ADDED
repeat with i from 1 to nbElements -- ADDED
properties of UI element i -- ADDED
end repeat -- ADDED
tell scroll area 1
class of UI elements --> {UI element, scroll bar}
tell UI element 1
class of UI elements --> {group, group, group, group, table, group}
tell group 1 to get class of UI elements --> {}
tell group 2 to get class of UI elements --> {}
tell group 3
--class of UI elements --> {static text}
tell static text 1
set {x, y} to its position
-- put the cursor at the very beg of the message
tell me to do shell script "/usr/local/bin/cliclick c:" & x & "," & y
-- type a space & a return character (don't use a linefeed)
keystroke space & return
-- triple click to select the entire new line
tell me to do shell script "/usr/local/bin/cliclick tc:" & x & "," & y
end tell
end tell -- group 3
tell group 4 to get class of UI elements --> {}
tell group 5 to get class of UI elements --> {}
end tell -- UI element 1
end tell -- scroll area 1
end tell -- window 1
-- decrease the quote level
tell menu bar 1
get name of menu bar items --> {"Apple", "Mail", "Fichier", "Édition", "Présentation", "Boîte aux lettres", "Message", "Format", "Fenêtre", "Aide"}
tell menu bar item format_loc to tell menu 1
get name of menu items --> {"Afficher les polices", "Afficher les couleurs", missing value, "Listes", "Style", "Alignement", missing value, "Indentation", "Niveau de citation", missing value, "Convertir au format texte"}
tell menu item quoteLevel_loc to tell menu 1
get name of menu items --> {"Augmenter", "Diminuer"}
click menu item decreaseQuoteLevel_loc
end tell -- menu item…
end tell -- menu bar item…
end tell -- -- menu bar 1
-- Now the quote level is OK but the text color is set to white. Why ?????
-- So trigger the dedicated UI element to reset it to black
tell window 1
class of UI elements -- ADDED <<<<<<<<<<<<<<<<<<<<
tell group 1
class of UI elements --> {pop up button, pop up button, color well, color well, group, group, menu button, menu button}
tell color well 1
click it
class of UI elements --> {pop over}
tell pop over 1
class of UI elements --> {button, UI element, UI element}
tell button 1 to get its name
tell UI element 1 to get class of UI elements --> {}
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, 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}
count buttons -->120
click button 12 --> black
end tell -- UI element 2
end tell -- pop over 1
end tell -- color well 1
end tell -- group 1
end tell -- window 1
tell window 1
class of UI elements --> {static text, text field, button, static text, text field, button, static text, text field, button, static text, text field, button, static text, text field, scroll area, pop up button, static text, button, button, button, toolbar, group}
tell scroll area 1
class of UI elements --> {UI element, scroll bar}
tell UI element 1
class of UI elements --> {group, group, group, group, table, group}
tell group 1 to get class of UI elements --> {}
tell group 2 to get class of UI elements --> {}
tell group 3
--class of UI elements --> {static text}
tell static text 1
set {x, y} to its position
-- put the cursor in the space character at the beg of the message
tell me to do shell script "/usr/local/bin/cliclick c:" & x + 5 & "," & y + 5
-- type the answer
keystroke myAnswer
end tell
end tell -- group 3
tell group 4 to get class of UI elements --> {}
tell group 5 to get class of UI elements --> {}
end tell -- UI element 1
end tell -- scroll area 1
end tell -- window 1
end tell -- System Events
tell application "Mail" to tell replyMessage
send -- send the message
end tell
end repeat
end Germaine
#=====
The log history is :
Don't clicl [Open this Scriplet in your Editor:]
Here is a log history
tell application "Mail"
localized string "QuoteLevel" from table "Compose"
--> "Niveau de citation"
localized string "DecreaseQuoteLevel" from table "Compose"
--> "Diminuer"
localized string "ToolbarComposeFormatBar"
--> "Format"
get selection
--> {message id 77185 of mailbox "Sent Messages" of account id "8466177C-3C92-4B82-BB40-EA424A398F0B"}
reply message id 77185 of mailbox "Sent Messages" of account id "8466177C-3C92-4B82-BB40-EA424A398F0B"
--> outgoing message id 4
end tell
tell application "System Events"
set frontmost of process "Mail" to true
get class of every UI element of window 1 of process "Mail"
--> {static text, text field, button, static text, text field, button, static text, text field, button, static text, text field, button, static text, text field, scroll area, pop up button, static text, button, button, button, toolbar, group}
get class of every UI element of scroll area 1 of window 1 of process "Mail"
--> {UI element, scroll bar, scroll bar}
get class of every UI element of UI element 1 of scroll area 1 of window 1 of process "Mail"
--> {group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, table, group, table, group, group, group, group, group, group, group}
get class of every UI element of group 1 of UI element 1 of scroll area 1 of window 1 of process "Mail"
--> {}
get class of every UI element of group 2 of UI element 1 of scroll area 1 of window 1 of process "Mail"
--> {}
get position of static text 1 of group 3 of UI element 1 of scroll area 1 of window 1 of process "Mail"
--> {456, 333}
end tell
tell current application
do shell script "/usr/local/bin/cliclick c:456,333"
--> ""
end tell
tell application "System Events"
keystroke "
"
end tell
tell current application
do shell script "/usr/local/bin/cliclick tc:456,333"
--> ""
end tell
tell application "System Events"
get class of every UI element of group 4 of UI element 1 of scroll area 1 of window 1 of process "Mail"
--> {}
get class of every UI element of group 5 of UI element 1 of scroll area 1 of window 1 of process "Mail"
--> {static text}
get name of every menu bar item of menu bar 1 of process "Mail"
--> {"Apple", "Mail", "Fichier", "Édition", "Présentation", "Boîte aux lettres", "Message", "Format", "Fenêtre", "Aide"}
get name of every menu item of menu 1 of menu bar item "Format" of menu bar 1 of process "Mail"
--> {"Afficher les polices", "Afficher les couleurs", missing value, "Listes", "Style", "Alignement", missing value, "Indentation", "Niveau de citation", missing value, "Convertir au format texte"}
get name of every menu item of menu 1 of menu item "Niveau de citation" of menu 1 of menu bar item "Format" of menu bar 1 of process "Mail"
--> {"Augmenter", "Diminuer"}
click menu item "Diminuer" of menu 1 of menu item "Niveau de citation" of menu 1 of menu bar item "Format" of menu bar 1 of process "Mail"
--> menu item "Diminuer" of menu "Niveau de citation" of menu item "Niveau de citation" of menu "Format" of menu bar item "Format" of menu bar 1 of application process "Mail"
get class of every UI element of window 1 of process "Mail" -- The ADDED instruction
--> {static text, text field, button, static text, text field, button, static text, text field, button, static text, text field, button, static text, text field, scroll area, pop up button, static text, button, button, button, toolbar, group}
get class of every UI element of group 1 of window 1 of process "Mail"
--> {pop up button, pop up button, color well, color well, group, group, menu button, menu button}
click color well 1 of group 1 of window 1 of process "Mail"
--> color well 1 of group 1 of window "Re: [Mailbutler] What can we do for you?" of application process "Mail"
get class of every UI element of color well 1 of group 1 of window 1 of process "Mail"
--> {pop over}
get class of every UI element of pop over 1 of color well 1 of group 1 of window 1 of process "Mail"
--> {button, UI element, UI element}
get name of button 1 of pop over 1 of color well 1 of group 1 of window 1 of process "Mail"
--> "Afficher les couleurs…"
get class of every UI element of UI element 1 of pop over 1 of color well 1 of group 1 of window 1 of process "Mail"
--> {}
get class of every UI element of UI element 2 of pop over 1 of color well 1 of group 1 of window 1 of process "Mail"
--> {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, 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}
count every button of UI element 2 of pop over 1 of color well 1 of group 1 of window 1 of process "Mail"
--> 120
click button 12 of UI element 2 of pop over 1 of color well 1 of group 1 of window 1 of process "Mail"
--> button 12 of UI element 2 of pop over 1 of color well 1 of group 1 of window "Re: [Mailbutler] What can we do for you?" of application process "Mail"
get class of every UI element of window 1 of process "Mail"
--> {static text, text field, button, static text, text field, button, static text, text field, button, static text, text field, button, static text, text field, scroll area, pop up button, static text, button, button, button, toolbar, group}
get class of every UI element of scroll area 1 of window 1 of process "Mail"
--> {UI element, scroll bar, scroll bar}
get class of every UI element of UI element 1 of scroll area 1 of window 1 of process "Mail"
--> {group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, group, table, group, table, group, group, group, group, group, group, group}
get class of every UI element of group 1 of UI element 1 of scroll area 1 of window 1 of process "Mail"
--> {}
get class of every UI element of group 2 of UI element 1 of scroll area 1 of window 1 of process "Mail"
--> {}
get position of static text 1 of group 3 of UI element 1 of scroll area 1 of window 1 of process "Mail"
--> {446, 333}
end tell
tell current application
do shell script "/usr/local/bin/cliclick c:451,338"
--> ""
end tell
tell application "System Events"
keystroke "Thank you.
The text gets inserted into the first line in the Mail reply message, but the signature and quoted text are deleted.
Is there a way to create a reply message, maintain the signature and quoted text, while inserting next text above it?"
get class of every UI element of group 4 of UI element 1 of scroll area 1 of window 1 of process "Mail"
--> {static text}
get class of every UI element of group 5 of UI element 1 of scroll area 1 of window 1 of process "Mail"
--> {static text}
end tell
May you re-try with this version and post the log history generated on your side ?
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) mardi 9 juin 2020 21:12:19
Added 4 instructions to get more infos about UI Elements existing in the reply window.