The approach shown in the StackOverflow answer I referenced earlier is to call ShouldAppsUseDarkMode (uxtheme\132). They also call !IsHighContrast(), but I can't find that function.A way to adapt a gui to the current dark/light mode is to query the registry to find the current mode:
Dark theme / Windows themed AHK
Re: Dark theme / Windows themed AHK
Re: Dark theme / Windows themed AHK
@lexikos , I just found that when a menu is split in columns with the Break or BarBreak Menu, Add options, the menu is not dark.
Is this something that can be fixed?
Is this something that can be fixed?
Author of freeware Quick Access Popup, the powerful Windows folders, apps and documents launcher!
Now working on Quick Clipboard Editor
The Automator's Courses on AutoHotkey
Now working on Quick Clipboard Editor
The Automator's Courses on AutoHotkey
Re: Dark theme / Windows themed AHK
I've only gone far enough to determine what I've already posted in this topic, and haven't even used any of it outside of basic tests.
Re: Dark theme / Windows themed AHK
@lexikos : I understand. If whenever you have time to dig this, at your convenience.
Or maybe someone else has an idea?
Author of freeware Quick Access Popup, the powerful Windows folders, apps and documents launcher!
Now working on Quick Clipboard Editor
The Automator's Courses on AutoHotkey
Now working on Quick Clipboard Editor
The Automator's Courses on AutoHotkey
Re: Dark theme / Windows themed AHK
Actually, I realized that this is to be expected. There are some cases where the menu falls back to classic Windows look, instead of the themed look, and this is one of those cases. It's hard to tell in Windows 10 because the themed look uses solid colours. If you compare the menu with BarBreak to one in light mode without BarBreak, you will see that the colours are different. Perhaps the theme data simply doesn't cover the elements needed to render the menu. Of course, UWP apps don't use Win32 menus to begin with.
It is likely that the only possible solutions are owner-drawn menus or a custom GUI. majkinetor wrote a script named MMenu back in 2007 that allowed complete customization of colours and fonts, and other features, but being so old it does not support Unicode/x64 and is hard to find.
It is likely that the only possible solutions are owner-drawn menus or a custom GUI. majkinetor wrote a script named MMenu back in 2007 that allowed complete customization of colours and fonts, and other features, but being so old it does not support Unicode/x64 and is hard to find.
Re: Dark theme / Windows themed AHK
@lexikos :Thanks for the explanation even if it's not very encouraging ;-)
I've considered this a few times and always concluded that I did ont want to take this route. Too much work and risk for the benefits (compare to code new or improved actual features).lexikos wrote: ↑27 Oct 2021, 18:18It is likely that the only possible solutions are owner-drawn menus or a custom GUI. majkinetor wrote a script named MMenu back in 2007 that allowed complete customization of colours and fonts, and other features, but being so old it does not support Unicode/x64 and is hard to find.
Author of freeware Quick Access Popup, the powerful Windows folders, apps and documents launcher!
Now working on Quick Clipboard Editor
The Automator's Courses on AutoHotkey
Now working on Quick Clipboard Editor
The Automator's Courses on AutoHotkey
Re: Dark theme / Windows themed AHK
This works perfect Thank you @lexikos for this!lexikos wrote: ↑23 Oct 2021, 18:30The module handle and function addresses do not change. To change the setting back, you need only the last two lines (assuming the variables are global or static).
I did not work out how to affect the menu bar, although I suppose you can use owner-drawn menus.
For Button controls (and maybe some others?), you can set the DarkMode_Explorer theme.I think the StackOverflow answer contains a workaround for the scroll bars, but I didn't look into it let alone translate it.Code: Select all
DllCall("uxtheme\SetWindowTheme", "ptr", ctrl_hwnd, "str", "DarkMode_Explorer", "ptr", 0)
...too bad it does not work on ListView Header (SysHeader321).
I know, I have to draw my own if I want to change the color (I found an old example for AutoIt > https://www.autoitscript.com/forum/topic/182405-solved-set-headercolumn-color-in-listview/ )
But I hoped to change the color easy
with best regards
KruschenZ
Re: Dark theme / Windows themed AHK
Here it is, the comments and suggestions in the thread may also help in case anyone is interested in a touch up for v2.
itros "ylbbub eht tuO kaerB" a ni kcuts m'I pleH
Re: Dark theme / Windows themed AHK
Hi there,
if someone also had problems to find out the HWND from a ComboLBox to color the Scrollbar dark:
https://www.autohotkey.com/board/topic/85044-get-hwnd-to-comboboxs-edit-field/
from @just me ; Thank you for that
with best regards
KruschenZ
if someone also had problems to find out the HWND from a ComboLBox to color the Scrollbar dark:
https://www.autohotkey.com/board/topic/85044-get-hwnd-to-comboboxs-edit-field/
from @just me ; Thank you for that
Code: Select all
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
PtrType := A_PtrSize ? "Ptr" : "Uint"
PtrSize := A_PtrSize ? A_PtrSize : 4
Gui, +LastFound
WinGet, hWindow,ID
Gui, Add, ComboBox, w400 r6 hwndHCBB, a|b|c|e|f|g|h|i|j|k
Gui, Show, , ComboBox & Edit
GetComboBoxInfo(HCBB, CBBInfo)
HCBBEDIT := NumGet(CBBInfo, 40 + PtrSize, PtrType)
HCBBLIST := NumGet(CBBInfo, 40 + (2 * PtrSize), PtrType)
HCBB += 0
ControlSetText, , % "ComboBox: " . (HCBB + 0) . " - Edit: " . HCBBEDIT . " - ListBox: " . HCBBLIST, ahk_id %HCBBEDIT%
DllCall("UxTheme.DLL\SetWindowTheme", "Ptr", HCBBLIST, "Str", "DarkMode_Explorer", "Ptr", 0)
Return
;_______________________________________________________________________________________________________________________
GuiClose:
ExitApp
;_______________________________________________________________________________________________________________________
GetComboBoxInfo(HCBB, ByRef CBBI)
{
; http://msdn.microsoft.com/en-us/library/bb775939%28VS.85%29.aspx
Global PtrSize, PtrType
CBBISize := 40 + (3 * PtrSize)
VarSetCapacity(CBBI, CBBISize, 0)
NumPut(CBBISize, CBBI, 0, "UInt")
Return DllCall("User32.dll\GetComboBoxInfo", PtrType, HCBB, PtrType, &CBBI)
}
KruschenZ
Re: Dark theme / Windows themed AHK
Wonderful, thanks guys, I've wanted dark menus from the taskbar for a while and randomly decided to search for a solution.
In my case, all my workstations are set up as Light "app mode", Dark "window mode" (ie dark taskbar, see screenshot), which yielded the dark menu solution in this thread non-functional.
The reason for this is that in older builds of Windows 10, the option was AllowDarkModeForWindow and boolean, but the SetPreferredAppMode options are something like:
So with my config, the API considers it still "light", but when my menu comes from the taskbar i want it to be dark like the other taskbar menus, so DllCall(SetPreferredAppMode, "int", 2) forces dark when I want it by using "2". 3 is obvious, and I haven't tried 4 yet to see what max means, but hopefully someone will find this useful.
In my case, all my workstations are set up as Light "app mode", Dark "window mode" (ie dark taskbar, see screenshot), which yielded the dark menu solution in this thread non-functional.
The reason for this is that in older builds of Windows 10, the option was AllowDarkModeForWindow and boolean, but the SetPreferredAppMode options are something like:
Code: Select all
0=Default
1=AllowDark
2=ForceDark
3=ForceLight
4=Max
Code: Select all
Menu_Dark(2)
Menu, Tray, Show
Menu_Dark(d) { ; 0=Default 1=AllowDark 2=ForceDark 3=ForceLight 4=Max
global Name, MenuIconSize
static uxtheme := DllCall("GetModuleHandle", "str", "uxtheme", "ptr")
static SetPreferredAppMode := DllCall("GetProcAddress", "ptr", uxtheme, "ptr", 135, "ptr")
static FlushMenuThemes := DllCall("GetProcAddress", "ptr", uxtheme, "ptr", 136, "ptr")
DllCall(SetPreferredAppMode, "int", d) ; 0=Default 1=AllowDark 2=ForceDark 3=ForceLight 4=Max
DllCall(FlushMenuThemes)
}
- Attachments
-
- Menu.png (40.29 KiB) Viewed 4177 times
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
Re: Dark theme / Windows themed AHK
I can't figure out how to make my Gui titlebar dark. The ListLines window is dark as stated, but I don't know how to execute this for my other Gui windows. I see screenshots from the other replies showing dark titlebars.
Edit: Nevermind. I had to call it BEFORE Gui, Show.
Edit: Nevermind. I had to call it BEFORE Gui, Show.
lexikos wrote: ↑25 Sep 2021, 02:28However, you can at least put the title bar into dark mode by calling DwmSetWindowAttribute via DllCall.DwmSetWindowAttribute need only be called once for each window.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
- tetratheta
- Posts: 35
- Joined: 16 Jan 2019, 13:28
Re: Dark theme / Windows themed AHK
I also wish AHK supports Windows' dark theme 'natively', but I think it must be almost impossible.
Even .NET WinForms, which would be first-party to MS, doesn't support dark theme nativly. They have opened issue for tracking it though.
Basically, those dark theme things are not well documented. All those workarounds I've found are using DllCall or P/Invoke for accessing internal methods. The closest way of using dark theme is this, but it has few limitations like Checkbox, ListView etc.
Even .NET WinForms, which would be first-party to MS, doesn't support dark theme nativly. They have opened issue for tracking it though.
Basically, those dark theme things are not well documented. All those workarounds I've found are using DllCall or P/Invoke for accessing internal methods. The closest way of using dark theme is this, but it has few limitations like Checkbox, ListView etc.
Who is online
Users browsing this forum: No registered users and 9 guests