Only UWP apps natively support the dark theme, so you should see that AutoHotkey is far from the only app that doesn't fit in.
There is as yet no documented way to put a window of a Win32 app into dark mode. The undocumented ways are shown here:
https://stackoverflow.com/a/58547831/894589
It makes reference to the undocumented "SetPreferredAppMode" function, which must be called before any windows are created. You cannot do this, because the script's main window is created before the script executes. I will not add it to the program, because the function is undocumented, the issue frivolous, and the solution incomplete.
However, you can at least put the title bar into dark mode by calling DwmSetWindowAttribute via DllCall.
Code: Select all
#requires AutoHotkey v1.1
if (A_OSVersion >= "10.0.17763" && SubStr(A_OSVersion, 1, 3) = "10.") {
attr := 19
if (A_OSVersion >= "10.0.18985") {
attr := 20
}
DllCall("dwmapi\DwmSetWindowAttribute", "ptr", A_ScriptHwnd, "int", attr, "int*", true, "int", 4)
}
ListLines
Pause
Code: Select all
#requires AutoHotkey v2.0-
if VerCompare(A_OSVersion, "10.0.17763") >= 0 {
attr := 19
if VerCompare(A_OSVersion, "10.0.18985") >= 0 {
attr := 20
}
DllCall("dwmapi\DwmSetWindowAttribute", "ptr", A_ScriptHwnd, "int", attr, "int*", true, "int", 4)
}
ListLines
Pause
DwmSetWindowAttribute need only be called once for each window.
Note the minimum required Windows 10 version.
According to my testing, this will make the title bar dark even if the system is set to "Light". The link above leads to C++ code demonstrating how to detect whether the app should use dark mode.
For changing the colours of the main window's Edit control, I suggest searching the forums for WM_CTLCOLOREDIT.
For the menus, I don't know. You could remove the menus with
DllCall("SetMenu", "ptr", A_ScriptHwnd, "ptr", 0) (but then you obviously can't use them).