[Feature Request] Action - Select Menu Bar Item

You know, the menu bar?

95% of the items might be selectable with an image locating action.

This one would be difficult though, because it's mostly text and it's dynamic based on state:

There's a lot of functionality in there I'd like to access:

Of particular interest to me are the 'Turn back start time' and 'Stop timer' sub-menus.

This would be similar to the "Select or Show a Show Menu" action but for the menu bar.

Is this possible?

The problem with selecting from the menu bar is there is no good way to identify them.

In this case, I would suggest you might be able to target the start or end of the menu image:

combined with limited the search to the small are of the screen that it can appear, something like:

That might be enough to get it working for you.

1 Like

Peter - In the past, I’ve experienced several instances where limiting the image search to a specific area, that it wouldn’t find the image at all. This was pre-7.1.

Is this something you’re aware of, or should I try to come up with a test case to show you? Thanks.

It’s not something I’m aware of, so a test case would be good.

The search area does need to be larger than the search image.

Here’s how you can test it:

With the KM Editor open and filling most of the screen, look for a unique image - say, the circled question mark at the bottom-right. Limit the search area to the location and size of the question mark, give or take. On my machine, anyway, it won’t find it until I change it to search the entire main screen (I have dual monitors, but I’m keeping KM on the main screen).

I believe it will also find it if I set the search area really large, but I tried that now and it didn’t seem to work, so not sure what I did differently this time.

Let me know if this helps.

Aww that's too bad but thanks for considering.

I thought about doing it as you mentioned, but I stopped that implementation because I suspected other similar menu bar items would interfere.

Especially this one:

Turns out the Tyme app has a keyboard shortcut for opening the menu bar.

What it doesn't have is a shortcut for the "Turn back start time" and "Stop timer" sub-menus. I can make a shortcut using images but I really liked the Menu > Sub-Menu features in Keyboard Maestro so I figured you'd want to replicate those with Menu Bar items.

Obviously there's no good way to do it so thanks for the consideration.

Hey Gregory,

What app are you working with here?

-Chris

Tyme for Mac - time tracking software. I love using this for work.

http://tyme-app.com

There’s nothing I can’t do when combining the apps existing keyboard shortcuts with found image macros so this feature request is more of a convenience ask for accessing menu bar items in general.

Hey Gregory,

Since I don't have Tyme I've done this detective work with Default Folder as a demonstration of the methodology involved. (It helps to have UI Browser, but that's a $55.00 dollar bill U.S.)

Substitute “tyme” and go through the steps in the Script Editor.app.

Look carefully at the result of each test and make the appropriate substitutions for the next test.

There's a reasonable chance you can get the Tyme menulette to open at the very least.

(It's certain – I found the Demo and tested with it.)

From there it's likely you can access menu items.

-Chris

-----------------------------------------------------
# Test 1
-----------------------------------------------------
tell application "System Events"
   UI elements whose name contains "Default Folder"
end tell
-----------------------------------------------------
# Test 2
-----------------------------------------------------
tell application "System Events"
   tell UI element "Default Folder X"
      UI elements
   end tell
end tell
-----------------------------------------------------
# Test 3
-----------------------------------------------------
tell application "System Events"
   tell UI element "Default Folder X"
      tell menu bar 2
         UI elements
      end tell
   end tell
end tell
-----------------------------------------------------
# Test 4
-----------------------------------------------------
tell application "System Events"
   tell UI element "Default Folder X"
      tell menu bar 2
         tell menu bar item 1
            actions
         end tell
      end tell
   end tell
end tell
-----------------------------------------------------
# Final Working Script
-----------------------------------------------------
ignoring application responses
   tell application "System Events"
      tell UI element "Default Folder X"
         tell menu bar 2
            tell menu bar item 1
               perform action "AXPress"
            end tell
         end tell
      end tell
   end tell
end ignoring
-----------------------------------------------------

Thanks @ccstone - I haven’t had a chance to dive into specific menu items but I will!

Hello @kraftyDevil, Is your question still current? I use Tyme 2 with Bartender 2

and have created me a KM macro selection. Here in the video you can see the process.

Since you happened to use Default Folder X as an example, I just wanted to add that it’s scriptable directly, without GUI scripting:

tell application id "com.stclairsoft.DefaultFolderX5" -- Default Folder X.app
	ShowMenu -- directParamText optional menu type ('Computer', 'Favorites', 'Recent Folders', 'Recent Files', 'Finder Windows', 'All')
end tell

Hey Michael,

True.

The trouble with this approach is that your AppleScript-runner app is hung until a selection is made in the menu.

Depending upon what you're doing that may or may not be an issue.

-Chris