-
Notifications
You must be signed in to change notification settings - Fork 588
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
Control applications in dock #953
Comments
Why not just bind hotkeys to applications themselves? |
Currently choosing an application icon which is in the Dock is not directly possible... you have to know the application's name or bundle-id to specify which application to activate/open with That said, if you're willing to use an experimental, still in progress, external module, I have been working on one at https://github.com/asmagill/hammerspoon_asm/tree/master/axuielement which should be able to do what you want... it's not currently (and may or may not ever be) part of the Hammerspoon core, so you'll need to manually add it, and it is still a work in progress, so syntax, etc. may change in the future, but I think something like this might do what you want: ax = require("hs._asm.axuielement")
d = hs.application("Dock")
iconNumber = 1 -- position in the dock, starting with 1 being the furthest left item
icon = ax.applicationElement(d)[1][iconNumber]
if icon:roleDescription() == "application dock item" then
icon:doPress()
else
print ("not an application")
end The exact mechanisms behind |
@nikitavoloboev @asmagill thanks! |
Hi and sorry to revive this thread. What was the outcome of the axuielement module? I see it's no longer available in the hammerspoon_asm repo. Thanks in advance! (I'm asking for the same reason: to automate access to the first 10 apps in dock using ctrl+1, 2, 3,... or something similar) |
@dgghita - You can find it here: https://github.com/asmagill/hs._asm.axuielement |
@latenitefilms - Thanks so much! (Off-topic: this looks like so much fun, can't wait to try it.) |
For anyone coming here in the year 2023, this is what I used for this feature and it works beautifully in macOS Ventura: d = hs.application("Dock")
for i=1,9 do
hs.hotkey.bind({"alt"}, tostring(i), function()
iconNumber = i
icon = hs.axuielement.applicationElement(d)[1][iconNumber]
if icon:attributeValue("AXRoleDescription") == "application dock item" then
icon:performAction("AXPress")
else
print ("not an application")
end
end)
end |
Hello, |
Not sure if this is a right place to ask questions.
Basically, what I am trying to do is to bind a shortcut to open 1st, 2nd, 3rd ... application in dock.
I have already checked the documentation here: http://www.hammerspoon.org/docs/hs.dockicon.html
But that is not what I want.
Thanks.
The text was updated successfully, but these errors were encountered: