Pages

2025/01/16

AutoHotkey (FREE) – Change Size and Position of The Active Window with Hotkey on Windows 11

I wanted to use a macro recorder to make my life easier but the problem was size and position of window must be the same every time in order to click or type at the right spot.


All of the free apps I had tried have no ability to serve me. I have to use AutoHotkey for this job

 

The test steps – AutoHotkey 1.1.37.02

On: Windows 11 Home

Download: https://www.autohotkey.com/

 

1. Go to the link above and download version 1.1.


Click the ‘Download’, you will see the options.

Open the downloaded file to install the app.


2. Open new document of Notepad.

 

^+w::

WinGetPos, X, Y, W, H, A

MsgBox, X, Y, W, H of the active window: %X%`, %Y%, %W%, %H%

 

Copy the code above (orange font), then paste it to Notepad.

This code is for getting size and position of active window by pressing

Ctrl+Shift+W.

You can change ‘w’ to the other. If I change it to ^+p, Ctrl+Shift+P is my hotkey.

Please take a look at the last line. After %X%, there is `. That is the code, not a typo.

Save a document and set the extension to .ahk.

3. Set the size and position of a window of Notepad the way you want.

Open the .AHK file.



Click an arrow at taskbar, you will see .AHK file (see picture above). That means it is running and detecting keystrokes. Whenever you press hotkey, message box will show values of size and position of active window (see picture below).


4. We have values of X, Y, W, H. The next step is the code for changing the size and position of active window.

 

^+z::WinMove, A,, 489, 192, 907, 572

 

From the code, you can change 358, 121, 1331, 818 to size and position you want.

Whenever you press Ctrl+Shift+Z, the size and position of the active window will be set.

You can change z to the other in ^+z

It’s time to do the same steps: copy the code above > create a new document of Notepad > paste it to Notepad > edit the code > save it > set the extension to .ahk > open a .AHK file.

Then make a target window active and press hotkey to change size and positon.


That’s it for this post. The next post I’ll show you the free app I use for recording macro.

 

The test steps – AutoHotkey 1.1.37.02

On: Windows 11 Home

Download: https://www.autohotkey.com/

 

No comments: