Give your AutoHotkey v2.1-alpha Gui windows a native dark title bar and a fully dark menu bar.
DarkMenuBar gives your AutoHotkey v2.1-alpha Gui windows a native Immersive Dark Mode title bar and a fully custom-painted dark menu bar (MenuBar). It hooks into the Win32 theme-drawing messages Windows uses for menus—WM_UAHDRAWMENU, WM_UAHDRAWMENUITEM, WM_NCPAINT, and WM_NCACTIVATE—and redraws them to match your window's background color, getting rid of that glaring white strip.
- Native Immersive Dark Mode title bar (using
DwmSetWindowAttribute). - Fully custom-painted dark menu bar, including the background, buttons, hover, pressed, and disabled states.
- Removes the 1px white line between the menu bar and the client area.
- Now supports AutoHotkey v2.0 via
DarkMenuBar_v2.0.ahk. - Zero external dependencies—seamlessly integrates with the v2.1 module system (
#Import).
You can also run DarkMenuBar.ahk directly to see it in action:
- AutoHotkey v2.1-alpha.30 or newer.
- Windows 10 or 11.
Since DarkMenuBar.ahk is a module, just drop it in the same folder as your main script and import it:
#Import 'DarkMenuBar'If you prefer keeping it in a Lib subfolder, use a relative path instead:
#Import 'Lib\DarkMenuBar'Importing the module automatically adds the SetDarkTitleBar and SetDarkMenuBar methods to the native Gui class, allowing you to call them directly on any Gui object:
myGui.SetDarkTitleBar()
myGui.SetDarkMenuBar()Full example:
#Requires AutoHotkey v2.1-alpha.30
#Import 'DarkMenuBar'
myGui := Gui('+Resize', 'Dark MenuBar')
myGui.BackColor := 0x202020
myGui.SetDarkTitleBar()
fileMenu := Menu()
fileMenu.Add('&New File', (*) => MsgBox('Hey~ <3'))
fileMenu.Add('&Open File', (*) => MsgBox('Hey~ <3'))
fileMenu.Add()
fileMenu.Add('E&xit', (*) => ExitApp())
editMenu := Menu()
editMenu.Add('Cu&t', (*) => 0)
editMenu.Add('&Copy', (*) => 0)
myGui.MenuBar := MenuBar()
myGui.MenuBar.Add('&File', fileMenu)
myGui.MenuBar.Add('&Edit', editMenu)
myGui.SetDarkMenuBar()
myGui.Show('w300 h200')Both functions are also exported by the module. If you'd rather use them as standalone functions instead of Gui methods, you can use named imports:
#Import 'DarkMenuBar' {SetDarkMenuBar, SetDarkTitleBar}
SetDarkTitleBar(guiObj)
SetDarkMenuBar(guiObj)| Function | Description |
|---|---|
SetDarkTitleBar(guiObj) |
Enables the native Immersive Dark Mode title bar. |
SetDarkMenuBar(guiObj) |
Enables the custom dark Win32 MenuBar drawing mechanism. |
DarkMenuBar 能讓 AutoHotkey v2.1-alpha 的 Gui 視窗擁有原生深色標題列及全深色選單列(MenuBar)。它透過攔截 Windows 繪製選單用的 Win32 主題訊息——WM_UAHDRAWMENU、WM_UAHDRAWMENUITEM、WM_NCPAINT、WM_NCACTIVATE——並根據視窗背景顏色重新繪製,讓選單列不再是那一條刺眼的白色長條。
- 支援原生的 Immersive Dark Mode 標題列(透過
DwmSetWindowAttribute實現)。 - 將選單列完整重繪為深色風格,包含背景、按鈕、滑鼠懸停 (Hover)、點擊及停用狀態。
- 消除選單列與視窗內容區(Client Area)之間那條 1 px 的白線。
- 現已透過
DarkMenuBar_v2.0.ahk支援 AutoHotkey v2.0。 - 零外部依賴,完美支援 v2.1 的模組系統(
#Import)。
你也可以直接執行 DarkMenuBar.ahk 來看看實際的呈現效果:
- AutoHotkey v2.1-alpha.30 或更新版本。
- Windows 10 / 11。
DarkMenuBar.ahk 本身是一個模組,請將它與你的主腳本放在同一個資料夾,然後匯入:
#Import 'DarkMenuBar'如果你習慣把它放在 Lib 子資料夾內,請改用相對路徑匯入:
#Import 'Lib\DarkMenuBar'成功匯入模組後,SetDarkTitleBar 和 SetDarkMenuBar 這兩個方法會自動註冊到原生的 Gui 類別裡,你可以直接在任何 Gui 物件上呼叫它們:
myGui.SetDarkTitleBar()
myGui.SetDarkMenuBar()完整範例:
#Requires AutoHotkey v2.1-alpha.30
#Import 'DarkMenuBar'
myGui := Gui('+Resize', 'Dark MenuBar')
myGui.BackColor := 0x202020
myGui.SetDarkTitleBar()
fileMenu := Menu()
fileMenu.Add('&New File', (*) => MsgBox('Hey~ <3'))
fileMenu.Add('&Open File', (*) => MsgBox('Hey~ <3'))
fileMenu.Add()
fileMenu.Add('E&xit', (*) => ExitApp())
editMenu := Menu()
editMenu.Add('Cu&t', (*) => 0)
editMenu.Add('&Copy', (*) => 0)
myGui.MenuBar := MenuBar()
myGui.MenuBar.Add('&File', fileMenu)
myGui.MenuBar.Add('&Edit', editMenu)
myGui.SetDarkMenuBar()
myGui.Show('w300 h200')模組同時也有把這兩個函式單獨匯出。如果你不想把它們當作 Gui 物件的方法,而是想當作一般函式來呼叫,可以使用具名匯入(Named Import):
#Import 'DarkMenuBar' {SetDarkMenuBar, SetDarkTitleBar}
SetDarkTitleBar(guiObj)
SetDarkMenuBar(guiObj)| 函式 | 說明 |
|---|---|
SetDarkTitleBar(guiObj) |
將視窗標題列設為原生的 Immersive Dark Mode 深色模式。 |
SetDarkMenuBar(guiObj) |
啟用 Win32 MenuBar 完整的深色重繪機制。 |
