-
Notifications
You must be signed in to change notification settings - Fork 594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is it possible to control menu items in dock context menus? #887
Comments
ATM, I don't think so (but chime in, anyone, if I'm wrong) but I have been giving thought to adding support in Hopefully this may spur an idea for someone more familiar with the menu search code; otherwise, I'll make sure to look into it myself when adding Dock menu creation support, hopefully in May. |
I'm less certain getting the menu list for Dock items will be quite that easy after looking at http://stackoverflow.com/questions/35821506/how-to-get-an-array-of-axmenuitems-from-axmenu/36115210#36115210... According to this and the Accessibility Inspector, it looks like the accessibility object for a Dock items menu doesn't actually exist until its visible... However, I do have a module I've been working off and on with that deals with AXUIElements directly... it needs a lot of cleanup and documentation and I haven't figured out how it fits in with the core modules yet, but it looks like it might be a step in the right direction if you (or anyone following this) wants to take a look... the module code can be found at https://github.com/asmagill/hammerspoon_asm/tree/master/axuielement... with it, I was able to pop up the menu for the Dock item for the System Preferences with (haven't tried selecting an actual menu item yet, as I'd need to write a function, rather than just use the console, since the menu takes focus away from the console): axuielement = require"hs._asm.axuielement"
SPDockItem = axuielement.applicationElement(hs.application("Dock")):elementSearch{title="System Preferences"}[1]
SPDockItem:doShowMenu() Looking at the code in the first link I gave above, I suspect that if this is followed with code to iterate through the children of SPDockItem ( I'll clean up the AXUIElement module and document it next week... it may be time to figure out where it fits in with Hammerspoon after all... |
Update: yeah, I think some variant of this needs to be added to Hammerspoon axuielement = require"hs._asm.axuielement"
SPDockItem = axuielement.applicationElement(hs.application("Dock")):elementSearch{title="System Preferences"}[1]
SPDockItem:doShowMenu()
SPDockItem[1]:elementSearch{title="General"}[1]:doPress() Note that elementSearch returns a list, which is why we add [1] after the I think something like this will do what you want if you change the two |
FYI, I've finally provided some documentation and a precompiled binary for the axuielement module. If you're interested, check out the Reference.md file in the repository folder. |
@asmagill is axuielement in shape for inclusion? :D |
Not yet... I realized recently that it leaks memory (not a lot, but it will add up)... I added code to allow direct comparison of the userdata objects and their use as keys in a table to help detect loops during traversal on the Lua side and didn't realize until recently that this code prevents the objects from ever being collected. And it still needs better documentation, so while I hope to add it into core at some point, it won't happen until the next release, I'm afraid. |
I'm going to close this out since it will either be solved or not by the fate of axuielement :) |
I fear the answer is "no", but since I don't have any experience with OS X APIs I thought I'd ask.
Context: Pandora is implemented as an Adobe Air (or whatever it's called) application, and its top bar menu doesn't provide any way to control the app. The dock menu does though:
I tried
p:findMenuItem('Play')
from the console, but that returnsnil
.P.S.: I searched the issues before but couldn't find any related questions to this.
The text was updated successfully, but these errors were encountered: