How to hide a specific window and not all window of the application? #3202
-
I'd like to hide only one or several windows but not the whole app. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
It's definitely possible, but you'll need to use the Accessibility Framework. |
Beta Was this translation helpful? Give feedback.
-
I'm a beginner and couldn't figure out how to do this with the Accessibility Framework but I came up with a solution that works for my needs. Posting in case anyone else wants to try it. I discovered that you can move individual windows to another Space on the Mac without sending the whole application. This in effect hides the application if you send it to a "empty" space. And with another command, you can bring back all the windows you sent to that Space and focus the most recent window you sent. Here is the code I used: -- move the currently focused window to Space with ID 2623
hs.hotkey.bind("cmd", "ctrl", "h", function()
local win = hs.window.focusedWindow()
local space = hs.spaces.focusedSpace()
-- hs.alert(space)
hs.spaces.moveWindowToSpace(win, 2623)
end)
-- Bring all "hidden windows" back to main Space
hs.hotkey.bind("cmd", "ctrl", "alt", "h", function()
local wins = hs.spaces.windowsForSpace(2623)
if #wins > 0 then
local focused = hs.window.find(wins[-1])
end
for key in pairs(wins) do
hs.spaces.moveWindowToSpace(wins[key], 1)
end
-- hs.alert(focused)
hs.window.find(focused):focus()
end) To adapt this script for your needs: Uncomment this line and hit the hotkey to find the ID's for your Spaces. First check the ID of your main Space, write that down. For me it's Edit this line and replace In the second hotkey binding, replace In this line, change the And this line is focusing the windows you just "unhid": I hope this is helpful. Bit of a workaround but works for my needs. Let me know if you try this out and it works for you. |
Beta Was this translation helpful? Give feedback.
It's definitely possible, but you'll need to use the Accessibility Framework.