Automator "Watch Me Do" using Command Down transition to AppleScript question.
I am using "Watch Me Do" to click two separate texts while holding down the Command button. It works when I replay the "Watch Me Do" block...in that it selects both texts at the same time:
However, when I drag these commands down to try to modify them (and run them faster) in AppleScript, it doesn't select them both (It doesn't work like it has the Command button held down). It just selects them individually one after the other:
on run {input, parameters}
-- Click the text “DAAF”
delay 0.627221
set timeoutSeconds to 2.0
set uiScript to "click static text 1 of group 9 of UI Element 1 of scroll area 2 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window XXXX\": Used by Apps\" of application process \"Safari\""
my doWithTimeout(uiScript, timeoutSeconds)
-- Click the text “DB2G”
delay 1.049824
set timeoutSeconds to 2.0
set uiScript to "click static text 1 of group 11 of UI Element 1 of scroll area 2 of UI Element 1 of scroll area 1 of group 1 of group 1 of tab group 1 of splitter group 1 of window XXXX\": Used by Apps\" of application process \"Safari\""
my doWithTimeout(uiScript, timeoutSeconds)
return input
end run
on doWithTimeout(uiScript, timeoutSeconds)
set endDate to (current date) + timeoutSeconds
repeat
try
run script "tell application \"System Events\"
" & uiScript & "
end tell"
exit repeat
on error errorMessage
if ((current date) > endDate) then
error "Can not " & uiScript
end if
end try
end repeat
end doWithTimeout
This above is all the code it generated when I copied the "Watch Me Do" commands. I have tried running the generated AppleScript code WHILE holding the command key down, but, again, it only selects each text separately.
I can't reveal the site (work thing), and I tried "using {command down}", and "with command key down". I also tried using the command key down with command key up later and took about an hour to figure out how to deal with a "stuck" command key. (Learning the try method now so I have an escape, but I had to open a new "Run AppleScript" with just the line: command key down in the same automator window in case I screwed it up again).
Since the "Watch Me Do" block CAN do this while it knows to hold down the command key, I have to believe that it can be Scripted. I have looked up uiScript and downloaded and started several AppleScript books trying to find this secret. Most of the pages online I have found to be 8-10 years old on topics identifying the "Class" name or ID, but nothing on Command Key.
If anyone has any ideas or can point me in a direction to figure this out, I would appreciate the time you take. Cheers
iMac 21.5″, macOS 10.13