If I understand well, you want to change the value of static texts but I don’t know if the value of these static text is always the same on entry or it may change.
If it’s always the same on entry it’s quite simple.
If it change, maybe these static texts have a property which remains stable, for instance, in a print dialog I see a static text whose some properties are: {title:missing value, help:" Haut 4,23 mm Bas 4,23 mm
Gauche 3,53 mm Droite 2,12 mm",value:“210 par 297 mm”, name:“210 par 297 mm”}
If I change the selected paper size from A4 to letter US, these properties become:
{title:missing value, help:" Haut 4,23 mm Bas 4,23 mm
Gauche 3,53 mm Droite 2,12 mm",value:“216 par 279 mm”, name:“216 par 279 mm”}
So I may identify the static text by its help and use:
set value of first static text whose help is " Haut 4,23 mm Bas 4,23 mm
Gauche 3,53 mm Droite 2,12 mm" to myValue
If such stable property doesn’t exist, you must use a table of target indexes.
For instance
your firstValue may have to target : static text 3 of group 2 of text area 1 of group 1 of group 5 of UI element 1 of scroll area 1 of group 1 of group 1 of window “Report” of application process “Salary” of application “System Events”
your secondValue may have to target : static text 7 of group 2 of text area 1 of group 1 of group 5 of UI element 1 of scroll area 1 of group 1 of group 1 of window “Report” of application process “Salary” of application “System Events”
your secondValue may have to target : static text 3 of group 2 of text area 3 of group 1 of group 5 of UI element 1 of scroll area 1 of group 1 of group 1 of window “Report” of application process “Salary” of application “System Events”
and so on.
In such case you may use :
on run
set theNames to {"aa", "bb"}
set theExtensions to {"1", "2"}
set thePF to choose from list theNames with prompt "Choose a prefix:"
if thePF is false then error number -128
set theExtension to item (getPositionOfItemInList((thePF as string), theNames)) of theExtensions
tell application "System Events" to tell process "Salary"
set frontmost to true
tell (first window whose subrole is "AXFloatingWindow")
set value of static text 3 of group 2 of text area 1 of group 1 of group 5 of UI element 1 of scroll area 1 of group 1 of group 1 to theExtension
end tell
--
end tell
end run
on getPositionOfItemInList(theItem, theList)
repeat with a from 1 to count of theList
if item a of theList is theItem then return a
end repeat
return 0
end getPositionOfItemInList
I don’t know who designed the target application but I think that using static text as container for a value modified by the user is poor design. Such container would better be text field or combo box.
In my example above, the static text wasn’t modified by the user. It’s the application which rule it according to the selection made in a pop up menu.
I hope that this long message is clear enough.
Let me know if it is.
If you really need to pass thrun the clipboard you need to use something like :
tell application "System Events" to tell process "Salary"
set frontmost to true
tell (first window whose subrole is "AXFloatingWindow")
tell static text 3 of group 2 of text area 1 of group 1 of group 5 of UI element 1 of scroll area 1 of group 1 of group 1
set {x, y} to its position
-- you may try to use : click at {x,y} -- but I doubt that it would work
tell me to do shell script "/usr/local/bin/cliclick c:" & x & "," & y -- third party CLI to click upon the static text
keystroke "v" using {command down}
end tell
end tell
end tell
Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France) jeudi 7 mai 2020 16:02:27