I want to have a window “fill” the screen, which can be done manually by selecting a window and then pressing the ctrl+globe+F keys simultaneously.
Is there a way to automate that with keyboard maestro? There are certain Windows that I want to always fill the screen ( not to be confused with fullscreen ) , and when I move the Dock to another display, they have a Dock-shaped gap at the bottom of the screen where the Dock was.
So , when I move the Dock, I want a quick way of resizing these windows to fill the screen.
I’m on macOS 26.5 and KM 11.0.4.
Update
I’m close, except only the front window is resizing. Even though I’m looping through all of the Windows and resizing and moving them in the same way. Internal is the builtin Macbook monitor that VS Code Windows are on.
A lot easier to help you were you to include / upload your macro, that way we can download and test it.
I am not at my desk at the moment to test your build but Keyboard Maestro only acts on the frontmost window which is likely why only the frontmost window is being resized, you need to bring each window to the front and then resize the windows as you loop through.
I changed the loop to count down instead of up, and change the index to a Local_ name. No change in the behavior. Foreground window is fills the screen, other windows - I opened a total of 3 VS Code windows with different sizes and locations - remain unchanged.
I noticed when I print the WINDOWCOUNT , it’s 1 even though I have 3 application windows opened.
Hmmm, I downloaded and tried your macro noting the following:
VS Code has a-typical window behaviour; for example, it does not respond to ⌘H. I Googled this and it is known bug.
VS Code's window count also does not work (don't know whether it is related to the bug in 1 above or not), for some reason as you noted (at least in Keyboard Maestro) it always reports 1 window, no matter how many are open. Perhaps @peternlewis or @Nige_S can shed some light as to why.
But.....the below AppleScript does what you want. at least on my MacBook [Note; VS Code's menu bar reads as Code].
tell application "Keyboard Maestro Engine"
set svLeft to (calculate "SCREENVISIBLE(Main,Left)") as integer
set svTop to (calculate "SCREENVISIBLE(Main,Top)") as integer
set svWidth to (calculate "SCREENVISIBLE(Main,Width)") as integer
set svHeight to (calculate "SCREENVISIBLE(Main,Height)") as integer
end tell
tell application "Code" to activate
tell application "System Events"
tell process "Code"
repeat with w in (windows whose value of attribute "AXMinimized" is false)
try
set position of w to {svLeft, svTop}
set size of w to {svWidth, svHeight}
end try
end repeat
end tell
end tell
Were it me, I would parametrize it further to read in i) the Application and ii) desired window position settings as it would allow you to use it as a sub-macro or subroutine.
@majorgear -- VS Code is a Microsoft app and an Electron app. Double the chance that something gets broken in any update! But perhaps there's another way...
You only care about the frontmost window of Code (if that) since when that's "Fill"ing the screen you can't see the other windows So why not just
...which should do what you want, compensating for Dock presence on that screen (tested with Dock hiding on and off). Depending on what you mean by
...you could trigger the macro on every VS Code front window change ("Fill" isn't a toggle, so there's no problem doing that when the window is already full). You should be able to add logic to finesse when it does or doesn't happen, but running it "needlessly" will have no impact on your system.
I'd also note that when I turn Dock hiding on and off a "Fill"ed window automatically resizes, even when not frontmost. The same is true when I reposition an always-on Dock. Does that not happen if you move the Dock?
And you get the nagging feel while using them that something isn't quite Mac-like...
The apps are bigger, and generally more resource hungry, because each app has (and runs) its own Electron framework. But the big giveaway is the the package contents: