Select item from a menu extras menu

Select item from a menu extras menu

Postby Ward » Fri Sep 24, 2010 4:01 pm

I'd like to assign a keyboard shortcut to a 3rd party menu extra action I perform numerous times a day. My three attempts failed:

  1. System Preferences > Keyboard > Keyboard Shortcuts let me assign a keyboard shortcut to the 3rd party menu extra app. But pressing the assigned shortcut keys does nothing.
  2. Likewise, Automator Record records the two clicks (menu icon + menu item), but playback simply drops down the menu (after a lengthy delay) and gives an error.
  3. So I tried a QuicKeys Recording of the the two clicks. The resulting shortcut has one step: Switch to [menu extra name]
Invoking this QK shortcut fails with this message: "Could not switch to [menu extra name]."

The single step actually works, after a fashion. I had a menu extra dialog window open from the recording; it became hidden behind the browser window I'm using to enter this note. When I pressed the shortcut keys, the dialog window popped to the front. But QuicKeys hung with its playback buttons shown in the menu bar until it gave up waiting and displayed the "Could not switch" error.

-- Ward
Ward
 
Posts: 59
Joined: Wed Apr 12, 2006 8:43 pm

Re: Select item from a menu extras menu

Postby gb2 » Fri Sep 24, 2010 4:19 pm

if it works what is the feature request?
User avatar
gb2
Site Admin
 
Posts: 2875
Joined: Mon Feb 06, 2006 6:22 pm

Re: Select item from a menu extras menu

Postby Ward » Fri Sep 24, 2010 4:44 pm

Instead of "The single step actually works, after a fashion," I should have written, "The single step makes an incomplete stab at activating the menu extra."

What actually appears to happen is QuicKeys tries to relaunch the 3rd party menu extra app, which is already running. This has the side effect of bringing its hidden dialog window to the front.

Bottom line: QuicKeys does not activate the 3rd party menu.

-- Ward
Ward
 
Posts: 59
Joined: Wed Apr 12, 2006 8:43 pm

Re: Select item from a menu extras menu

Postby gb2 » Sat Sep 25, 2010 11:51 am

there are hundreds of different ways that third party menu extras can be written and QuicKeys isn't going to be able to handle them all. It sounds like QuicKeys couldn't get the menu item and the program is bringing up an application so that is why you have the "Switch to" that isn't working. What is the program and menu item you want to select? I'll take a look and see if it can be done some other way.
User avatar
gb2
Site Admin
 
Posts: 2875
Joined: Mon Feb 06, 2006 6:22 pm

Re: Select "Call..." from the Phone Amego menu

Postby Ward » Sat Sep 25, 2010 12:11 pm

Thanks, gb2, for the insight into menu extras.

The menu extra app is Phone Amego. I'd like a keyboard shortcut for the "Call..." menu item.

One of the things I looked into before opening this thread was having QuicKeys use AppleScript to "poke" Phone Amego. But Phone Amego's limited set of app-specific AppleScript commands doesn't include Open Call Window. If QuicKeys doesn't pan out, I plan to ask for that AppleScript command.

-- Ward
Ward
 
Posts: 59
Joined: Wed Apr 12, 2006 8:43 pm

Embarrassed!

Postby Ward » Sat Sep 25, 2010 3:48 pm

I sent the URL of this thread to Peter Sichel, the Phone Amego developer. He responded:
You can define a "hot key" to open the Call window from with Phone Amego itself under the More tab. I use Control-Shift-C. Click on the hot key control next to "Open Call Window Hot Key:" and type the key combination you want to use.

That takes the immediate pressure off. Of course, now that I have a shortcut for the Call window, I can foresee desiring shortcuts for the "Hang Up" and "Phone Amego..." menu items. (At the moment, Phone Amego's shortcut preference is just for the Call menu item.)

-- Ward
Ward
 
Posts: 59
Joined: Wed Apr 12, 2006 8:43 pm

Re: Select item from a menu extras menu

Postby gb2 » Mon Sep 27, 2010 10:08 am

I tried getting it to work with AppleScript and couldn't. The icon in the menu is a button and is owned by the application but it doesn't specify a window or any other container that it is in, so there isn't a way to access it.
User avatar
gb2
Site Admin
 
Posts: 2875
Joined: Mon Feb 06, 2006 6:22 pm

Can menu extras be more QuicKeys friendly?

Postby Ward » Mon Sep 27, 2010 10:18 am

Thanks, gb2, for investigating the automation of the Phone Amego menu. It's unfortunate that Mac OS X does not provide a menu extras framework that provides hooks for QuicKeys and other accessibility apps.

Are there menu extras techniques developers can use to make their menus QuicKeys friendly?

-- Ward
Ward
 
Posts: 59
Joined: Wed Apr 12, 2006 8:43 pm

Re: Select item from a menu extras menu

Postby gb2 » Mon Sep 27, 2010 10:53 am

it does - Status Bar Programming Topics - I'm not sure why they don't use it.
User avatar
gb2
Site Admin
 
Posts: 2875
Joined: Mon Feb 06, 2006 6:22 pm

Re: Select item from a menu extras menu

Postby psichel » Mon Sep 27, 2010 12:18 pm

Hello, I'm the developer of Phone Amego. I followed the link above (Status Bar Programming Topics), but it mostly just describes the Cocoa API for creating a Status Bar item which Phone Amego uses. Can you say more about what other techniques you think a Status Bar item like Phone Amego might use to make it more easily scriptable?

One possible disconnect is that Phone Amego sets the "Application is agent (UIElement)" flag. This means it does not appear in the Dock or have a menu bar of its own. This was a deliberate design decision to minimize any disruption of the current task when the user tries to access one of their phones.

My understanding so far is that Mac OS X does not provide a mechanism to define keyboard shortcuts for Status Bar items, thus I included an explicit Hot Key mechanism to open the Call window within the application itself.

Kind Regards,

- Peter
psichel
 
Posts: 2
Joined: Mon Sep 27, 2010 11:32 am

Re: Select item from a menu extras menu

Postby gb2 » Mon Sep 27, 2010 1:02 pm

I wasn't concerned that it didn't have keyboard shortcuts for the menu items but that it isn't acting like the other menu items supplied like the Time or Spaces. They show as being owned by SystemUIServer and it supplies a menu bar that the items can be accessed from. Other third party items that I have seen are buttons that are owned by the application and can't be accessed with QuicKeys. You can use the Apple's Accessibility Inspector that comes with the Developer Tools to see what I mean. I don't know maybe Apple doesn't supply third parties with the same API's that the other ones are written in - that's all that I know about the subject.
User avatar
gb2
Site Admin
 
Posts: 2875
Joined: Mon Feb 06, 2006 6:22 pm

Keyboard access to "status" menus

Postby Ward » Mon Sep 27, 2010 1:55 pm

One of the dead ends I went down in my exploration was using keyboard traversal of menu extras:

  1. System Preferences > Keyboard > Keyboard Shortcuts: enable "Move focus to status menus".
  2. Click ^F8 to move keyboard focus to the right end of the menu bar -- Time Machine is selected.
  3. Use right- and left-arrow keys to change menu selection.
Unfortunately, the menu selection is limited to the Apple-supplied menus: in my case, Time Machine, Time and AppleScript. This seems to be further evidence that Apple is using API features not available to developers.

-- Ward
Ward
 
Posts: 59
Joined: Wed Apr 12, 2006 8:43 pm

Re: Select item from a menu extras menu

Postby psichel » Mon Sep 27, 2010 8:48 pm

The two API's are mentioned here: Wikipedia Menu Extra

"Menu extras were introduced with Mac OS X v10.1 to replace Dock extras (docklings),... There was some controversy when they were originally introduced due to Apple providing an API for third-party developers to use to create menu extras using the NSStatusItem class, while Apple used another private class called NSMenuExtra to develop their own menu extras. Menu extras based on NSMenuExtra automatically included a number of extra features not available to NSStatusItem-based extras, such as drag and drop install/uninstall and the ability to rearrange the extras by depressing the ⌘ key and dragging. The given reason for this is that NSMenuExtra-based menu extras operate within the address space of the SystemUIServer so faulty code in a menu extra could cause instability in a core part of the operating system."

As far as I know, NSMenuExtra remains a private undocumented API which I consider a red flag when a published alternative is available.

- Peter
psichel
 
Posts: 2
Joined: Mon Sep 27, 2010 11:32 am


Return to QKM Feature Requests

Who is online

Users browsing this forum: No registered users and 3 guests

cron