Size Matters
Testing your program for small screens? You could change your own monitor's resolution, but that gets annoying real fast. Here's a better way.

If you're like me, the monitor on your development machine has a much higher resolution than many (all?) of your users. It's easy to forget about users with less screen real estate when designing an interface on a massive monitor.
How do you know what your program will look like on a smaller screen? You could change your screen's resolution temporarily. But that gets annoying real fast.
My solution, once again, was to turn to AutoHotkey. I created a script where I could preconfigure some common screen resolutions. When I want to see what an application looks like at a lower resolution, I simply click on the application to give it the focus, then right-click on my script's icon to choose one of those preconfigured resolutions. The active window is immediately resized to the new resolution and centered on screen.

This bit of code will add a submenu to the right-click menu of your script's notification area icon. The script should be self-explanatory. To customize it, you just add or remove the "Menu, ResizeWin..." lines.
#Persistent ; Keep the script running
; Build Menu
Menu, ResizeWin, Add, 1920 x 1080, ResizeWindow
Menu, ResizeWin, Add, 1280 x 1024, ResizeWindow
Menu, ResizeWin, Add, 1366 x 768, ResizeWindow
Menu, ResizeWin, Add, 1024 x 768, ResizeWindow
Menu, ResizeWin, Add, 800 x 600, ResizeWindow
Menu, Tray, Add, Resize Window, :ResizeWin
Return ; Prevent automatically resizing the current window when the script is launched
ResizeWindow:
StringSplit, Dims, A_ThisMenuItem, x
Msg =
if (A_ScreenWidth < Dims1)
{
Dims1 := A_ScreenWidth
}
if (A_ScreenHeight < Dims2)
{
Dims2 := A_ScreenHeight
}
X := (A_ScreenWidth - Dims1) / 2
Y := (A_ScreenHeight - Dims2) / 2
If (X < 0)
X := 0
If (Y < 0)
Y := 0
Send !{ESC}
WinRestore, A
WinMove, A, , %X%, %Y%, %Dims1%, %Dims2%
ToolTip, Window resized to %Dims1% x %Dims2%
SetTimer, RemoveToolTip, 5000
Return
RemoveToolTip:
SetTimer, RemoveToolTip, Off
ToolTip
Return
UPDATE (11/23/2020): Thanks to Anders Ebro (@TheSmileyCoder) for pointing out some bugs in the original script I posted. I incorporated the fixes into the code sample. I'll try to be more careful about testing my code standalone before posting in the future ;-)