Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Using /Developer/Applications/Utilities/Accessibility Tools/Accessibility Inspector.app you can use the built-in accessibility system to look at properties of the UI element under the mouse. Take special note of the cmd-F7 action to lock focus on an element and the Refresh button. Sadly the element and property names don't directly match those in the script suite, but you can look at the dictionary for System Events or usually guess the right terminology.</p> <p>Using this you can determine two things. First, the <code>focused</code> property isn't on the <code>menu item</code>, but rather there is a <code>text field</code> within the <code>menu item</code> that is focused. Second, the menu item has a <code>selected</code> property.</p> <p>With this, I came up with:</p> <pre><code>tell application "System Events" tell (first process whose frontmost is true) set helpMenuItem to menu bar item "Help" of menu bar 1 -- Use reference form to avoid building intermediate object specifiers, which Accessibility apparently isn't good at resolving after the fact. set searchBox to a reference to menu item 1 of menu of helpMenuItem set searchField to a reference to text field 1 of searchBox if searchField's focused is true then key code 53 -- type esc else click helpMenuItem end if end tell end tell </code></pre> <p>Though this still doesn't work. The key event isn't firing as far as I can tell, so something may still be hinky with the <code>focused</code> property on the text field.</p> <p>Anyway, your <code>click</code> again solution seems much easier.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload