0

Okay, using a program called "Notability" for taking notes now. I would like to create a shortcut for changing text colors, etc. However, I'm having trouble scripting the UI. The changing colors is not in the menu bar (otherwise it would be a piece of cake).

I'm trying to click on the color selection (see image below), but I'm getting an error. Not sure what exactly it means.

Here's the website.

Here's what I get from a window inspection tool I use:

application Process "Notability"
    window 1 Note Aug 6, 2018
        button 1
        menu button 1
        menu button "117%"
        radio group 1
            radio button 1
            radio button 2
            radio button 3
            radio button 4
            radio button 5
        checkbox 1
        checkbox 2
        button 2
        text field 1
            button 1
        scroll area 1
            outline 1
                row 1
                    UI element 1
                        static text "6"
                        static text "All Notes"
                row 2
                    UI element 1
                        static text "0"
                        static text "Unfiled Notes"
                row 3
                    UI element 1
                        static text "2018-19 Fall"
                        UI element 2
                row 4
                    UI element 1
                        static text "1"
                        static text "Education"
                row 5
                    UI element 1
                        static text "0"
                        static text "Am Pol Theory"
                row 6
                    UI element 1
                        static text "0"
                        static text "Python"
                row 7
                    UI element 1
                        static text "0"
                        static text "Astro"
                row 8
                    UI element 1
                        static text "2018-19 summer"
                        UI element 2
                row 9
                    UI element 1
                        static text "5"
                        static text "Bold"
                column 1
        menu button 3
        progress indicator 1
        button 3
        button 4
        scroll area 2
            table 1
                row 1
                    UI element 1
                        static text "5 product inclusion Aug 6, 2018"
                        static text "Today at 3:04 PM"
                        image 1
                        image 2
                row 2
                    UI element 1
                        static text "4 Tech&Culture Aug 6, 2018 (2)"
                        static text "Today at 1:59 PM"
                        image 1
                row 3
                    UI element 1
                        static text "1 Note Aug 6, 2018"
                        static text "Today at 1:37 PM"
                        image 1
                        image 2
                row 4
                    UI element 1
                        static text "2 Keynote Note Aug 6, 2018 (2)"
                        static text "Today at 1:37 PM"
                        image 1
                        image 2
                row 5
                    UI element 1
                        static text "3 Who is google Note Aug 6, 2018"
                        static text "Today at 1:37 PM"
                        image 1
                        image 2
                column 1
            scroll bar 1
                value indicator 1
                button 1
                button 2
                button 3
                button 4
        scroll area 3
            scroll bar 1
                value indicator 1
                button 1
                button 2
                button 3
                button 4
        button "1x"
        button 6
        button 7
        slider 1
            value indicator 1
        static text "58:33"
        checkbox 3
        button 8
        static text "Text Styling"
        static text "Size:"
        static text "Style:"
        static text "Lists:"
        static text "Color:"
        pop up button 1
        pop up button 2
        radio group 2
            radio button 1
            radio button 2
            radio button 3
        pop up button 3
        pop up button 4
        button 9
        button 10
        button 11
        static text "1 Note Aug 6, 2018"

Here's my accessibility inspector:

<AXApplication: “Notability”>
 <AXWindow: “5 product inclusion Aug 6, 2018”>
  <AXPopUpButton>

Attributes:
   AXEnabled:  “1”
   AXParent:  “<AXWindow: “5 product inclusion Aug 6, 2018”>”
   AXSize:  “w=51 h=27”
   AXFocused (W):  “0”
   AXChildren:  “<array of size 0>”
   AXRole:  “AXPopUpButton”
   AXTopLevelUIElement:  “<AXWindow: “5 product inclusion Aug 6, 2018”>”
   AXHelp:  “(null)”
   AXPosition:  “x=1334 y=260”
   AXValue:  “”
   AXWindow:  “<AXWindow: “5 product inclusion Aug 6, 2018”>”
   AXRoleDescription:  “pop up button”
   AXFrame:  “x=1334 y=260 w=51 h=27”

Actions:
   AXShowMenu - show menu
   AXPress - press

Here's my code so far:

tell application "System Events"
    tell process "Notability"
        tell window 1

            click "pop up button"

        end tell
    end tell
end tell

Here's the error I'm getting:

error "System Events got an error: Can’t make \"pop up button\" into type UI element." number -1700 from "pop up button" to UI element

Here's an image of the section I'm trying to script:

enter image description here

4
  • Notability needs to be activated before System Events can act on one of its UI Elements, e.g. add tell application "Notability" to activate and a delay 0.5 before the tell application "System Events" block. Additionally you need to be specific about which pop up button to click, you can just say click "pop up button" without saying which pop up button. Commented Aug 7, 2018 at 11:41
  • Thank you! I tried to do that (I added the line you mentioned and also told it to click pop up button 1) just now and it's still giving me the same error. Any other thoughts? Commented Aug 8, 2018 at 4:37
  • I do not have Notability, so the only thing I can suggest is to use Automator to record clicking on the Color button to get the AppleScript code from the Watch Me Do action it creates. Have a look at this answer: Drag to convert Automator Action into Applescript Commented Aug 8, 2018 at 12:16
  • Thanks! I already have done that for keyboard maestro. Oh well. Maybe someone else will know. Appreciate the help. Commented Aug 9, 2018 at 4:01

1 Answer 1

1

I thought that since I do have this app that I'd take a look at it. Normally I avoid UI scripting to every extent possible but having been compelled to do so recently, I decided that playing around with this might help me understand it better. I did at least get a headache out of the effort. Anyway, I don't believe it is possible (at least with my v4) because the final UI element doesn't seem to have an associated action.

But as it's possible that a more recent version might have more functionality or that someone more proficient can identify how, here is a script that gets up to the colour palette.

NB 'pop up button 4' is the 'Color' dropdown in the screen shot. The 'AXPress' action grabs the popup but doesn't present the palette. 'key code 76' simulates the 'return' key, bringing up the palette (pop over 1) but there are multiple alternatives. Also, if the palette is already showing, an error will result.

tell application "System Events" to tell front window of application process "Notability"
    tell pop up button 4 to perform action "AXPress"
    key code 76
end tell

Either of these lines should 'click' the second colour (orange in the default palette) but do nothing in my version (each result is 'missing value').

click group 2 of list 1 of list 1 of pop over 1 of pop up button 4
tell group 2 of list 1 of list 1 of pop over 1 of pop up button 4 to perform action "AXPress"

If you add this line it will generate some variation of the result below. In this example, the third colour (red) has an image (checkmark) which indicates the active colour for the selection.

UI elements of groups of list 1 of list 1 of pop over 1 of pop up button 4

--> {{}, {}, {image 1 of group 3 of list 1 of list 1 of pop over 1 of pop up button 4 of window "Note Mar 31, 2020" of application process "Notability" of application "System Events"}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .