If you’re a Windows user, you know how to resize windows using the AutoHotkey keyboard shortcut. But what if you want to resize windows in more than one way? For example, you might want to resize windows in a specific size or position, or resize them all at once. In this article, we’ll show you how to resize windows using AutoHotkey in three different ways.

  1. Resize all windows at once: This is the easiest way to resize windows. Just type “resize window” into the AutoHotkey keyboard shortcut and press Enter. The window will be resized according to the number of keyspresses that are made. You can also use this command while a window is open so that it will affect all of its siblings that are open at the same time.
  2. Resize one window at a time: To resize one window, type “resize window” into the AutoHotkey keyboard shortcut and press Enter. Then use the arrow keys to move the cursor around until you’ve found the size that you want for your window. Press Tab to continue moving the cursor around until you’ve found your desired size. The window will be resized according to how many keys are pressed on average (the number of siblings that are open).
  3. Resize all windows by dragging them left or right: To resize all windows by dragging them left or right, type “resizewindow” into the AutoHotkey keyboard shortcut and press Enter. Then use arrow keys to move around until you’ve found your desired size and position for your window(s). Press Tab to continue moving the cursor around until you’ve found your desired size and position for your Window(s).

We’re going to assume that you’ve already downloaded and installed AutoHotkey, and you’ve got some type of idea how it all works. If you don’t, you might want to read through their tutorial.

The Scenario

Here’s a sample video that shows the script in action, so you can understand what we’re going to be creating today. The basic idea is that we’ll be resizing windows to specific dimensions, or only resizing by either width or height while leaving the other the same.

Create the AutoHotkey Script

You’ll want to start out by creating a blank AutoHotkey script and putting the following code into it. This is the function that we’ll use to resize windows with some hotkey definitions later on. You can, of course, put this function into your existing script as well.

The “A” in the script means that it will work on the active window—you could replace that with the title of a specific window if you wanted. You’ll notice the first line in the function grabs the current width/height and X/Y position, which is then used in the script in case width/height are not set, and to leave the current X/Y position on the screen in the same place.

  If %Height% = 0    Height := H

  WinMove,A,,%X%,%Y%,%Width%,%Height%}

Resize a Window to Specific Width / Height

This is perhaps the most useful function for web developers, who might want to resize a browser to specific dimensions to test out a page design. Sure, there’s loads of applications and browser plugins that do the same thing, but if you’re an AutoHotkey user all you need is a few extra lines of code to eliminate all that overhead.

To resize to a specific width and height, you’ll want to use the function like this:

You can then assign it to a hotkey, in this case we’ll be using Win+Alt+U as the hotkey to resize the current active window to 800×600.

 Resize a Window to a Specific Width

You can also leave off the height parameter when calling the function to only resize the window width but not the height. This is probably less useful, but I’ve found that it works out well when you have a very large screen and want to resize a number of windows to fit side-by-side on the screen.

For instance, this line would assign the Win+Alt+U hotkey to resize the window to 640 pixels wide and leave the height the same:

 Resize a Window to a Specific Height

To resize a window to a specific height while leaving the width the same, just pass in 0 as the height parameter. For example, to resize the current window to 400 pixels tall when you press Win+Alt+U, you’d use this line:

It’s a useful function that you can drop into your AutoHotkey script—even if you don’t need it right now, it’s probably useful to save for later. We’ve also got a downloadable version of the script you can use here:

Download ResizeWindows AutoHotkey Script from howtogeek.com