Maximize Window When Dragging to the Top of the Screen (Also Left and Right Halves)

I use BetterTouchTool and I am able to automatically maximize a window by dragging it to the top edge of the screen, almost like a HotCorner, but for the top of the screen.
Is this possible to achieve with KM? If so, how?
At this point I'm just using BTT for that and if I can replace that behavior with KM, one less app that's running.

Note: I really want it to be used with the mouse drag, not a keyboard shortcut, because I got used to that workflow and since I also use the default HotCorners from the macOS, it's better to keep the same type of workflow.

EDIT: I ended up figuring it out using some of the solutions provided and here are the 3 options I came up with:
Window - Maximize.kmmacros (20 KB)
Window - Left Half.kmmacros (20 KB)
Window - Right Half.kmmacros (20 KB)

I have an idea, but it wouldn't be as neat and tidy. I'm not able to try right now but I can do tomorrow.

If I were you, I'd consider keeping BTT as it adds some nice functionality to KM. There's no harm having both running on your machine; a lot of users here do.

1 Like

Something like this? The MOUSEY check is there so it only triggers when you move the window to the top of the screen and push the pointer through into the menu bar, helping prevent a loop when you un-Full Screen a window that's at the top of the screen...

(Something doesn't look right though -- do I really need a CALCULATE in a calculation field to access an array by index? Gurus?)

1 Like

Welp, that's actually pretty neat and tidy!

While it does answer @iamdannywyatt's question, I'm not sure it's the best solution! We're asking KM to run this macro on practically every window move (unless you limit it to certain apps) and, depending on how BTT does this, switching to KM-only may be more resource-intensive overall than having BTT running in the background.

But it did let me have some fun with FrontWindowFrame :wink:

1 Like

For reasons he explained to us earlier, iamdannywyatt is still trying to replace BTT completely with KM. I am still sure that this must fail. It just doesn't make sense to replace tasks that one app can do well with another that can't. We should be glad that there are different apps that complement each other perfectly and take advantage of the opportunities to use both.

With all the drawbacks that the BTT forum has, the software itself is evolving rapidly and has introduced more fantastic innovations in the last 4 weeks than other software in 4 years. And what is still to come this year is so great that it would be a real pity to do without it.

So iamdannywyatt, do yourself a favor and don't exclude yourself from this :slight_smile:

1 Like

Even though my issue with the BTT forum is one of the reasons, that's not the only reason. At this point, I'm only using BTT for the window resize function. Everything I've build with BTT so far, is replaceable with KM, so having an app pretty much just for maximizing a window, seems a bit useless (if I can/could replicate the same effect using KM).

Does it mean I will not ever find something that I can't accomplish using KM and really need BTT? I don't know. So far, my workflow only needed things that KM does. And of course, that in conjunction with the forum issue, makes me think that I'm just having an extra app that doesn't do much, but it's still there running (or at least, it's there on the menu - OCD kicking in haha).

Another reason (and this my even sound that I'm contradicting myself or saying something that can cause more harm than good), is that by having a lot of companies I rely on, I have to depend on all of them to keep updating their software, dealing with multiple customer care emails (when some of them don't even reply), dealing with multiple forums, etc. So if KM has a forum that's very active, I end up having to only go to a place to find solutions. Sure, I'm putting all my eggs in one basket and that's an issue, but... it's a risk I'm willing to take if that means having fewer apps on my computer and all that.

Since this is something I do here and there, maybe that's not that bad? It's not that I'm using this feature every 5 minutes or anything. Do you think this would make a significant difference?

I just tried this macro and it's not working...
I'm not sure if the macro isn't working, of if I didn't clearly explain what I'm trying to achieve. Or both... haha

When I use this macro it doesn't do anything at first. If I then try to keep moving the window+mouse to the top edge for like 2-3 more times it eventually opens the Mission Control window, which I just tested with both BTT and KM disabled, and it seems to be the default behavior that comes with the macOS, so it seems that the macro is not working at all.

Any suggestions?

It's something you "do" every time you move a window -- KM has to run the macro to decide whether or not the move is or is not one that should trigger the zoom. So it depends on how often you move windows.

It works for me -- shove window to top, window goes into full screen mode. I know that's not a lot of help, but... What app are you testing in? I just used the KM editor window. Are you doing this on the main or secondary display? Are you pushing the window up and pushing through with the mouse into the menu bar without stopping or releasing the mouse button, so the "move" finishes with the window at the top and the mouse pointer in the menu bar?

Default behaviour for Mission Control is a 3 or 4 finger swipe up on a trackpad or double-tap on a Magic Mouse. Sounds like you've got something else going on...

Yes that's what I mean, I rarely move windows, because I pretty much just work with maximized windows all the time. That's why this macro would help, because every time a window is not maximized, I just drag and make it maximized to match my workflow.

Here's what I'm doing. It's easier to show the 3 options (1 is the default without BTT or your macro; 2 is with BTT as my default; 3 is with your macro).

Not sure if you tried it yourself, but see if you get the same behavior? Besides BTT, there's nothing I have installed that could change this behavior, so I'm assuming this is some kind of default thing...
Yes, I get the same effect when using the 3 or 4 finger swipe, but I also get this other one. See if you experience the same thing.

I see what you mean. You're getting Mission Control/Spaces because you are pushing past the top of the menu bar rather than stopping within it. When you go into Full Screen mode, which is what "Zoom" does, the app involved gets put into its own Space. Your Mac is obviously quicker than mine so has time to show the "Space" interface before you release the mouse button/trackpad.

And because your Mac is quicker than mine the macro's "window stopped moving" happens while your cursor is well short of the menu bar -- only one condition is true so the macro doesn't trigger. You could make the "activation area" bigger by increasing the number in the MOUSEY comparison, but that could get really annoying. Or make the trigger a two-stepper -- triggered by "window moved to top", a short pause, then an "if mouse position" that either Zooms the window or cancels the macro.

Or keep using BTT, which probably does this all much better :wink:

Question: When you say you "pretty much just work with maximized windows all the time", do you mean the old maximised or the new-style Full Screen?

Yes, that's how BTT works and I love that, because I don't have to think too much, I just drag as much as possible and boom! Done!

It's a MacBookPro 2012, with 8GB Ram. Nothing fancy.

I just tried it again, reaaaaaaal slow, didn't drag it all the way up, just dragged it to the top menu, like in the middle of the menu bar, but no luck. I am either not getting how it works, the macro doesn't work on my computer, or something else is going on. Can you please make a video or take a screenshot? I'm really confused...

I don't understand this part, because I don't understand how the macro is supposed to work, since it's not working on my end. Can you clarify what the actions are doing, one by one, so I can understand your thought process?

The old-fashion way. To be honest, I hate the full screen mode and I see no advantage at all in it. With so many other things that Apple could have improved that hasn't worked for years and lots of users have complained, I don't see why this was such a priority... but, Apple being Apple, you know? haha I'm sure some people like it, but I'm just saying I don't see why that became a priority instead of fixing things that people have complained for years

Wrong way round -- you needed to be quick! The problem is the "both conditions need to be true" and your Mac notices the window hitting the top and tests the mouse condition before your mouse has moved any further.

But that's all academic. The mouse position check was there because without it you could never get out of Full Screen mode -- switching out put the window back under the menu bar, which triggered the macro and put it back into Full Screen mode! Not such an issue if you want old-style maximise instead.

What I don't know is if "window hits menu bar" will be enough to interrupt the Mission Control activation you're getting when you push on through -- BTT may be able to do that by working at a lower level. Time to have a play and find out!

I'm trying to test something, but I don't know how to achieve this, because there's no trigger that uses the mouse position.

Is it possible to do this:
When the mouse's vertical position is 0 (so at the very top) it maximizes the front window? Because that's pretty much what I need. That's how the hot corners work as well, no need to grab a window.

If this can be achieved, maybe it's easier and I will be happy with it :slight_smile:

Try this. It works the same way -- drag window to top, follow through to menu bar to maximise the window. As written it'll resize the window to the visible screen, ie doesn't go "behind" the Dock. It might work on multiple monitor setups, resizing the window to which ever display it is on -- that'll depend on whether the trigger works...

So the trigger is the same -- a moved window's top is against the menu bar (using "less than or equal to 25" because I can't remember if extra displays have menu bars to bump against!). There's a brief pause so you can position a window without maximising it -- if you do want to, push the pointer into the menu bar. The resize should be self-explanatory -- resize the active window the visible area of the display the pointer (mouse) is currently on. If you do want to go "behind" the Dock change the references to SCREENVISIBLE to SCREEN, and add 25 to the Top calculation.

I'm sure there are some gotchas, especially on multiple-monitor setups. But give it a go and see how you get on.

Window Maximise.kmmacros (4.8 KB)


Ok I will try it tonight. Gotta do some stuff here first.
One thing I noticed, not sure if this is causing the issue. I took a screenshot of only the menu bar and when I open it with Preview, I see that the screenshot is actually 1280 by 22 (not 25). Do you think this matters?

Thanks for sharing this, it's working pretty well for me!

Not sure why it would be different, but my menu bar is only 23 pixels so once i changed that it worked great.

On 10.14.6

So you're saying that changing it to 23 is what makes it work?

@Nige_S and @Evan_Mangiamele
So changing mine to 23 also made it work so I guess the issue was just that.

Ok some issues: now I have a folder icon on my menu bar and when I click it it shows me Window Maximize:
Screen Shot 2022-06-17 at 9.08.33 PM

Why is this there and how to remove it?

Also, the macro is working, but it's "glitchy". When I drag it, it seems as if it's trying to resize and move it left and right, like a glitch. It eventually works, but it's a bit "annoying" to the eyes. Do you also experience this? if so, do you know what that is?
I tested the other version with the Full Screen, and it glitches as well.

1 Like