(How) Can I extract a string from a window object in an application?

I'd like to store the name of a patient from an EMS in a variable.
The name is not in the window title, so that does not help. The %WindowName%1% always yields the same result.

The name is displayed in an "object" of the window.

Is there any way to extract this information and store it in a variable? With or without KM?

What is the app you are using?

You'll probably need AppleScript to get that text. If you can identify the UI element that contains the text of interest, you can get it using AppleScript.

The best way to determine the UI element is using a tool like UI Browser. If you don't own it, you can download a free trial version.

Also, you can try this great tool by @ccstone:

Once you have the full path of the element of interest, you can get its text property using a script like this:

Example of Getting Text (or Value) of UI Element

Note Path to the selected group Element:

  window "Keyboard Maestro Editor"
    scroll area 1 of splitter group 1 of group 1
      first group whose selected is true


tell application "System Events"
  tell application process "Keyboard Maestro"
    tell window "Keyboard Maestro Editor"
      set macroGroupArea to scroll area 1 of splitter group 1 of group 1
      set macroListArea to scroll area 2 of splitter group 1 of group 1
      tell macroGroupArea -- Macro Group Scroll Area
        set groupSel to first group whose selected is true
        --   This uses the "name" property, but it could also be "value", or "title", or "description".
        set groupName to name of groupSel
      end tell
    end tell
  end tell -- process "Keyboard Maestro"
end tell -- "System Events"

return groupName

If you can get the full path to the UI element of interest, and need help with the AppleScript, post back here and we'll try to help.

1 Like