Code and Documentation
What is it?
At work I have the opportunity to work on a 4K monitor from time to time. I have quite a few scripts with GUIs and even though the scaling is set to 150% and AutoHotkey scales the GUI automatically - see https://autohotkey.com/docs/commands/Gui.htm#DPIScale - I still find it often too small / inconvenient to use.
As I didn't want to redo all the GUI sizes, control positions, etc or scale all the coordinates manually so the GUI would be usable on various DPI settings, I wrote a simple function to do all the work dynamically. I still have to modify the GUI code but now not that much editing is needed and it will scale the GUI depending on the DPI setting set by the user.
Example: here is a GUI at 144 DPI before and after applying dpi():
(at 96 dpi the GUI will probably look huge)
If you want to disable the scaling you can set the dpi by simply calling the function see
setdpiin the documentation.
Simple GUI code before DPI()
You can simply call the dpi() function by wrapping it around the options like so: