Bernard Harte

Q: UI Scripting - Attribute Value

Is it possible to get an attribute value when UI scripting?

 

Using the Accessibility Inspector I can see an attribute accessibilityVisibleRows in an AXOutline element, but I don't know how to get hold of it.

MacBook Pro, OS X El Capitan (10.11.5), 16GB RAM

Posted on Jul 6, 2016 11:59 AM

Close

Q: UI Scripting - Attribute Value

  • All replies
  • Helpful answers

  • by Pierre L.,

    Pierre L. Pierre L. Jul 6, 2016 7:17 PM in response to Bernard Harte
    Level 5 (4,484 points)
    Jul 6, 2016 7:17 PM in response to Bernard Harte

    To begin with, try statements like the ones below, one at a time:

     

    tell application "System Events"

         tell process "Finder"

               attributes of outline 1 of

               name of attributes of outline 1 of

               value of attributes of outline 1 of

               value of attribute [name of attribute] of outline 1 of

         end tell

    end tell

  • by Pierre L.,Helpful

    Pierre L. Pierre L. Jul 7, 2016 7:47 AM in response to Bernard Harte
    Level 5 (4,484 points)
    Jul 7, 2016 7:47 AM in response to Bernard Harte

    I should have written “tell process [name of process]” instead of “tell process "Finder"”.

  • by Bernard Harte,

    Bernard Harte Bernard Harte Jul 7, 2016 7:53 AM in response to Pierre L.
    Level 4 (3,309 points)
    iPhone
    Jul 7, 2016 7:53 AM in response to Pierre L.

    I"ve only just had a chance to try your suggestions - though I think I had been through them all before.

     

    If I do:

    value of attribute "AXVisibleRows"

     

    it returns a list:

     

    {application "System Events", application "System Events", application "System Events", application "System Events", application "System Events", application "System Events", application "System Events"}

     

    However, since I know in this instance that the value is 7, I think I can get what I need by:

     

    count of (value of attribute "AXVisibleRows")

     

    The app is "Audio MIDI Setup" which is a built-in Apple app.  The object I am addressing is:

     

    outline 1 of scroll area 1 of splitter group 1 of window "Audio Devices"

  • by Pierre L.,

    Pierre L. Pierre L. Jul 7, 2016 8:12 AM in response to Bernard Harte
    Level 5 (4,484 points)
    Jul 7, 2016 8:12 AM in response to Bernard Harte

    Could the code below help you get the information you are looking for?

     

    tell application "Audio MIDI Setup" to activate

    tell application "System Events"

         tell process "Audio MIDI Setup"

               value of text fields of rows of outline 1 of scroll area 1 of splitter group 1 of window "Audio Devices"

         end tell

    end tell

    --> {{"Built-in Microphone"}, {"Built-in Input"}, {"Built-in Output"}}

  • by Bernard Harte,

    Bernard Harte Bernard Harte Jul 7, 2016 8:24 AM in response to Pierre L.
    Level 4 (3,309 points)
    iPhone
    Jul 7, 2016 8:24 AM in response to Pierre L.

    Thanks Pierre.  I think it's getting closer, but I have a multi-output device as the last row.  Unfortunately this just returns an empty list item at that row. (Although I can see it's different from the other single interfaces, I can't really be sure it's the correct item.)

     

    Perhaps if I explain what I am trying to achieve (at least at this part of the problem):

     

    A multi-output device has a disclosure triangle which I can click using UI scripting.  I am trying to work out whether it has been clicked (and, hence, it's subitems are revealed) or v-v before I then proceed to manipulate the UI of the revealed rows.

  • by Pierre L.,Solvedanswer

    Pierre L. Pierre L. Jul 7, 2016 9:02 AM in response to Bernard Harte
    Level 5 (4,484 points)
    Jul 7, 2016 9:02 AM in response to Bernard Harte

    Unfortunately, I have no multi-output device I could connect to my MacBook Pro. However, in case it might help, here's how the state of a disclosure triangle can be checked in Mail:

     

    tell application "Mail" to activate

    tell application "System Events"

         tell process "Mail"

               value of UI element 3 of UI element "Inbox" of row 2 of outline 1 of scroll area 1 of splitter group 1 of window "Inbox (52 messages)" --> 0 or 1

         end tell

    end tell


    Edit — UI element 1 of UI element "Inbox" is the static text, UI element 2 of UI element "Inbox" is an image.

  • by Bernard Harte,

    Bernard Harte Bernard Harte Jul 7, 2016 9:04 AM in response to Pierre L.
    Level 4 (3,309 points)
    iPhone
    Jul 7, 2016 9:04 AM in response to Pierre L.

    Aha!  That will do it.  Thanks.

  • by Pierre L.,

    Pierre L. Pierre L. Jul 7, 2016 9:07 AM in response to Bernard Harte
    Level 5 (4,484 points)
    Jul 7, 2016 9:07 AM in response to Bernard Harte

    You're welcome. I'm glad I could help.