I’m trying to use AppleScript in an automator workflow to get text from a window that I just opened via the same AppleScript.
Essentially here is what is happening with the script:
Script is called using a keystroke with text selected
Script gets open application and executes command+0 to open a file (in this case a patient chart in proprietary patient management software) then command+L to create a letter. New window with letter pops open correctly.
This letter window contains an element that I cannot seem to get to with AppleScript. Ideally I would like to capture the value contained in this element (in this case the url https://some.website.somewhere/indext.html?var=value… ) and then subsequently open the URL in Safari.
This element is a text area (dashed line around the outside). When double clicking on it then inspecting it with Accessibility inspector it is AxTextArea and I’m trying to get the Value property which contains the string/URL
I’ve tried scroll area 1 of window 1 but from there I don’t know how to access this element.
Any ideas? Sorry, new user, it won’t let me post more than one image at a time so I took a combined screenshot.
Sort of…The element that contains the text is of type text entry area with a parent scroll area. It’s confusing though because I find this by clicking on the desired object, but the scroll area does not seem to show it as a child. Its confusing.
application "System Events"
tell application process "Tops Ortho"
UI element of window 1
end tell
end tell
yields
{scroll area 1 of window "*End of Treatment Letter Helper" of application process "topsXtreme" of application "System Events", button 1 of window "*End of Treatment Letter Helper" of application process "topsXtreme" of application "System Events", button 2 of window "*End of Treatment Letter Helper" of application process "topsXtreme" of application "System Events", button 3 of window "*End of Treatment Letter Helper" of application process "topsXtreme" of application "System Events", static text "*End of Treatment Letter Helper" of window "*End of Treatment Letter Helper" of application process "topsXtreme" of application "System Events"}
and the following
tell application "System Events"
tell application process "Tops Ortho"
get count (scroll areas of window 1)
end tell
end tell
But…I’m discovering that it only works if the text entry area is in focus and in a mode where the text can be edited. Shoot I thought I had it. Any other clues?
Only the two scroll bars and popup button. dashed line square that the text is in is nowhere to be found until it is clicked on and cursor enters the text area.
It is of type “text entry area”. Accessibility Inspector shows that the element class is “PlaceholderTextView”
This element is not present in either Accessibility Inspector or UI Browser until it is double clicked on to place the cursor inside as if to edit it. Hope that makes sense. See Screenshot.
None, unless the box has been clicked on to enter and the cursor is in there. Then it shows up.
I’ve tried to script a double click there but that is also not working for me. The scroll area 1 of window 1 I can get to. The resulting text entry area of class PlaceholderTextView I cannot seem to get my script to access.