Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 38821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T14:46:05+00:00 2026-05-10T14:46:05+00:00

I have a script for OS X 10.5 that focuses the Search box in

  • 0

I have a script for OS X 10.5 that focuses the Search box in the Help menu of any application. I have it on a key combination and, much like Spotlight, I want it to toggle when I run the script. So, I want to detect if the search box is already focused for typing, and if so, type Esc instead of clicking the Help menu.

Here is the script as it stands now:

tell application 'System Events'     tell (first process whose frontmost is true)         set helpMenuItem to menu bar item 'Help' of menu bar 1         click helpMenuItem     end tell end tell 

And I’m thinking of something like this:

tell application 'System Events'     tell (first process whose frontmost is true)         set helpMenuItem to menu bar item 'Help' of menu bar 1         set searchBox to menu item 1 of menu of helpMenuItem         if (searchBox's focused) = true then             key code 53 -- type esc         else             click helpMenuItem         end if     end tell end tell 

… but I get this error:

Can’t get focused of {menu item 1 of menu ‘Help’ of menu bar item ‘Help’ of menu bar 1 of application process ‘Script Editor’ of application ‘System Events’}.

So is there a way I can get my script to detect whether the search box is already focused?


I solved my problem by working around it. I still don’t know how to check if a menu item is selected though, so I will leave this topic open.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T14:46:06+00:00Added an answer on May 10, 2026 at 2:46 pm

    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.

    Using this you can determine two things. First, the focused property isn’t on the menu item, but rather there is a text field within the menu item that is focused. Second, the menu item has a selected property.

    With this, I came up with:

    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 

    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 focused property on the text field.

    Anyway, your click again solution seems much easier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this script that run to fix my menu bar to the browser
I have script that handles image rollovers with css. What I would like to
I have a script like this: (but it's not working) $('div#selectbox select:focus').parent().css('box-shadow','0 0 4px
I have script that reads remote file content and writes it to local server.
I have a script that recursively loops through all the sub directories and compresses
I have a script that submits data via an ajax POST. It is called
I have following script that executes all the .reg files in the current directory.
I have a script that obtains information about the current folders and subfolders within
I have a script that resizes called resize Here is the script: <? echo
I have a script that uses a ton of redirects. About half way through

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.