Skip to content

Latest commit

 

History

3 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

DarkMenuBar

Give your AutoHotkey v2.1-alpha Gui windows a native dark title bar and a fully dark menu bar.

English · 正體中文


English

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.

Features

  • 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).

Demo

You can also run DarkMenuBar.ahk directly to see it in action:

DarkMenuBar Demo

Requirements

  • AutoHotkey v2.1-alpha.30 or newer.
  • Windows 10 or 11.

Installation

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'

Usage

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')

API Reference

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_UAHDRAWMENUWM_UAHDRAWMENUITEMWM_NCPAINTWM_NCACTIVATE——並根據視窗背景顏色重新繪製,讓選單列不再是那一條刺眼的白色長條。

特色功能

  • 支援原生的 Immersive Dark Mode 標題列(透過 DwmSetWindowAttribute 實現)。
  • 選單列完整重繪為深色風格,包含背景、按鈕、滑鼠懸停 (Hover)、點擊及停用狀態。
  • 消除選單列與視窗內容區(Client Area)之間那條 1 px 的白線。
  • 現已透過 DarkMenuBar_v2.0.ahk 支援 AutoHotkey v2.0
  • 零外部依賴,完美支援 v2.1 的模組系統(#Import)。

效果展示

你也可以直接執行 DarkMenuBar.ahk 來看看實際的呈現效果:

DarkMenuBar 展示

系統需求

  • AutoHotkey v2.1-alpha.30 或更新版本
  • Windows 10 / 11。

安裝

DarkMenuBar.ahk 本身是一個模組,請將它與你的主腳本放在同一個資料夾,然後匯入:

#Import 'DarkMenuBar'

如果你習慣把它放在 Lib 子資料夾內,請改用相對路徑匯入:

#Import 'Lib\DarkMenuBar'

使用方式

成功匯入模組後,SetDarkTitleBarSetDarkMenuBar 這兩個方法會自動註冊到原生的 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')

API 參考

模組同時也有把這兩個函式單獨匯出。如果你不想把它們當作 Gui 物件的方法,而是想當作一般函式來呼叫,可以使用具名匯入(Named Import):

#Import 'DarkMenuBar' {SetDarkMenuBar, SetDarkTitleBar}

SetDarkTitleBar(guiObj)
SetDarkMenuBar(guiObj)
函式 說明
SetDarkTitleBar(guiObj) 將視窗標題列設為原生的 Immersive Dark Mode 深色模式。
SetDarkMenuBar(guiObj) 啟用 Win32 MenuBar 完整的深色重繪機制。

Releases

Packages

Contributors

Languages