Override system dpi scaling.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
Zseni
Posts: 53
Joined: 03 Nov 2019, 19:44

Override system dpi scaling.

10 May 2021, 02:27

Idk if this is possible, but I would like it if the ahk script file is able to change its own properties to this when ran.
Capture.PNG
Capture.PNG (168.59 KiB) Viewed 730 times
Or just to be able to override the system dpi scaling somehow? I don't want to do it manually and the system dpi scaling stuffs up the fonts.

Much appreciated.
lexikos
Posts: 9583
Joined: 30 Sep 2013, 04:07
Contact:

Re: Override system dpi scaling.

10 May 2021, 03:26

So SeizeControl is a compiled script, and you want it to use the "System (Enhanced)" scaling mode automatically, without the user having to set it?

When you say "the system dpi scaling stuffs up the fonts", to what are you referring? The above setting is system DPI scaling.

AutoHotkey's GUI commands perform their own scaling of fonts and coordinates if you do not add the -DPIScale option to your GUI. This is not the system DPI scaling. Default font sizes are dependent on the DPI regardless of -DPIScale.

If you use multiple monitors and they have different DPI settings, I think the system scaling might kick in automatically because AutoHotkey is not "per-monitor DPI aware". But the system (non-enhanced) scaling doesn't do anything with fonts; it renders the window at its normal size (for the primary screen in our case) into an off-screen image, then scales the entire image to display on-screen.

You cannot effectively change the setting while AutoHotkey is running, as it does some initialization at startup that depends on its default DPI awareness - such as determining A_ScreenDPI. However, you can set the scaling mode for windows you create.

Code: Select all

; DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED := -5
DllCall("SetThreadDpiAwarenessContext", "ptr", -5, "ptr")

Gui Add, Text,, This text should be scaled using the "System (Enhanced)" method.
Gui Add, Button, gExit, Exit
Gui Show
return
Exit:
ExitApp
Each window uses whatever setting was current at the time the window was created.

If you are launching or reloading the script, you can override DPI awareness via the __COMPAT_LAYER environment variable (which is handled by the system):

Code: Select all

EnvGet compat_layer, __COMPAT_LAYER
if InStr(compat_layer, "GDIDPISCALING")
    Gui Add, Text,, This text should be scaled using the "System (Enhanced)" method.
else
    Gui Add, Text,, This text should be scaled using AutoHotkey's DPIScale.
Gui Add, Button, gReload, Reload
Gui Show
return
Reload:
EnvSet __COMPAT_LAYER, GDIDPISCALING
Reload

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Lamron750, Rohwedder and 241 guests