AppleScript to Get text from an obscure object AXTextArea

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:

  1. Script is called using a keystroke with text selected
  2. 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.
  3. 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.

Screenshot 2025-11-17 at 1.56.31 PM

Doesn’t “Accessibility Inspector” show the hierarchy of the element?

You can investigate by doing things like:
tell app “System Events”
tell app process “topsOrtho”
ui elements of window 1
end tell
end tell

( Sorry about the lack of formatting - posting from my phone. )

Then, depending on what result you get, add the sub-elements into that “ui elements of” line, until you find the object.

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.