Hi, this is Gary with MacMost.com. Today
let me show you three ways to center a window on your Mac.
MacMost is brought to you thanks to a great group of more than 1000 supporters.
Go to MacMost.com/patreon. There you can read more about the Patreon Campaign.
Join us and get exclusive content and course discounts.
Now let's say you wanted to center a window on your Mac. Like bring this one right to the middle.
It's almost impossible to get it perfectly in the middle by just dragging it. So it would be nice
to have a simple way to automatically center it. Let me show you three different ways to do this
all of which have advantages and disadvantages.
First it would be great if there was a way to do it without installing any third party
applications, doing any kind of scripting, shortcuts, automation or anything like that.
You can do this using standard windows movements and commands on your Mac.
Now you can combine two windows movement tricks to center a window. First you have to get the window
to fill the entire screen. I'm not talking about using the green button or going to full screen in
any way. I'm talking about having this window actually enlarged to fill the whole screen.
You can do that by double clicking with the Option key held down on any corner.
The double click will make it snap to the corner. Holding Option key down will do the
same thing for the opposite corner. So just pick your favorite corner, like the bottom left here,
Option double click on it and now this window fills the whole screen.
You may think that, well I can do the same thing with double clicking on the title bar like that.
That will work in some windows but not others because technically that only expands the window
to the size needed for the content. So in some cases, like in Safari, that's not going to work.
But Option double clicking on a corner will always expand the windows to the maximum size.
Now with any corner you can use Option and drag and it will drag all corners at the same time.
Now you've got a perfectly centered window and you can make it any
size that you want. Just drag to the size you want and stop. It seems like a lot of steps but
it's really not. Here's me doing it really quickly. Option double click. Option drag
and I'm done. I've got a window centered. The disadvantage to this is it takes a couple of steps
and you really don't get the window back to the exact size you had it before.
Now let's do this using Scripting in the new Shortcuts App. There are actually two methods to
do it, both of which have issues. The first is to use the command, Move Window. When you add that,
you can see I added that right here, the default is Move Windows to Center. Perfect. That's exactly
what we wanted to do. But how do you get the window to move? Unfortunately Shortcuts doesn't
have a good answer to that. There is the Find Windows Where. You could see it right here.
This will search for available windows. But it is super slow. I don't really have very much going
on here in this demo, but if you had a couple of full screen apps like maybe Safari and Mail,
it could take more than a minute to actually find the current window and it can't actually
even find the current window because all of the filters here have to do with things like Title,
App Name, and all of that. There's no way to tell it
just find the front-most window from the current app. It's just not available here.
So I had to write this piece of JAVA script that basically gets the title
of the current window of the current app. Then it feeds that in here and you filter Title Is
and that result. So it's going to basically find the window that has the same title as this
one here. Then it will center that window. Now I've set this up to Pin in Menu Bar so it will
appear here to let me go to my TextEdit window here and use this. You could see
it works. But trust me, if you had a few more apps open this would be too slow to be usable.
Now a few years ago I showed you how to actually do this using Automator.
You can take that same script and use it here in Shortcuts. So here's the actual same script.
It's exactly the same script here that uses JAVA script to get the front-most
window from the front-most app. Then it figures out the size of your desktop by
looking at the Finder and then it will put the window in the middle keeping the same
size. So this is all in JAVA Script. It doesn't have the same problem that the previous shortcut
did of taking a long time to figure out the current window. So it works rather quickly.
One issue here is when you run it you can see it doesn't quite work. What did it do there? Why did
it put it there? That is actually the center of my desktop. If I show you System Preferences displays
you could see here's the window that you see. I actually have a second screen here. So actually
putting it right there, that's actually the center of my desktop. So this doesn't really
work very well if you've got multiple displays. But it works perfectly if you have a single
display. You could remedy this by actually using hard-coded numbers here. So I could do 1280, 720,
and I could just have zeroes for the left and top. Then I don't even need this anymore. Now
if I want to center a window like this I can run the script and it works fast and accurately.
So if you have multiple windows then this is the kind of script that you want
and put the width and height of your main monitor in there. But if you have just a
single screen then doing this will always work and you don't have to enter in the numbers.
So as you can see there are a lot of disadvantages using Shortcuts.
The first shortcut will take too long to run. Maybe Apple can fix that in the
future by giving us a quick way to get the front-most window of the front-most app.
The other shortcut works great for a single screen but you have to customize it for multiple screens,
and it requires a little bit of coding which not everybody is comfortable with.
Now you could also just get a third party app to do this. There are a ton of these in
the App Store. If you search for Window Managers you can download one of these.
They will cost a little bit but they have a lot of advanced functionality besides just
centering the window. You could also find some outside of the App Store. Sometimes they are
free. A really popular one right now is Rectangle which has a free and a paid Pro Version and you
could get it here. The free version will allow you to center a window. So I'm going to launch it here
and I've got it now in the Menu Bar and I could see one of the commands here is for Center.
The keyboard shortcut is Option Command C so I could just use Option Command C.
It will center the current window. The disadvantage of this method is you need
to add yet another third party app to your system in order to do it. But if it's something that you
require and maybe you want some of this other functionality as well then it might be worth it.
So there are three methods you can use to center a window. Each has advantages and disadvantages.
But each could also be used to do more than just centering a window.
For instance those window movement techniques I showed you at first could be used to do other
things to position windows around. The Shortcuts can be used to position the windows in other ways
to specific spots on the screen, for instance. The third party apps have a lot more features
than just the ability to center windows. You can use them to position windows and save
presets and all sorts of things. So I hope you found this useful. Thanks for watching.