暗黑托盘菜单栏 标题栏 按钮.ahk
; https://www.autohotkey.com/boards/viewtopic.php?f=13&t=94661 #Persistent Menu_Dark(2) ; 以下是暗黑按钮代码 Gui +HwndGuiID Gui, Add, Button, vMyButton gTest, Test GuiControlGet, hwndMyButton, Hwnd, MyButton DllCall("uxtheme\SetWindowTheme", "ptr", hwndMyButton, "str", "DarkMode_Explorer", "ptr", 0) ; 普通按钮 Gui, Add, Button, gTest, Test ; 暗黑标题栏【Hwnd适用于其它窗口】 ; if (A_OSVersion >= "10.0.17763" && SubStr(A_OSVersion, 1, 3) = "10.") ; attr := A_OSVersion >= "10.0.18985" ? 20 : 19, DllCall("dwmapi\DwmSetWindowAttribute", "ptr", hGui1, "int", attr, "int*", true, "int", 4) ; 暗黑标题栏【Hwnd适用于其它窗口】 if (A_OSVersion >= "10.0.17763" && SubStr(A_OSVersion, 1, 3) = "10.") ; Win10+暗黑标题栏 DllCall("dwmapi\DwmSetWindowAttribute", "ptr", GuiID, "int", A_OSVersion >= "10.0.18985" ? 20 : 19, "int*", true, "int", 4) /* ; 暗黑标题栏 原版双if判断 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", GuiID, "int", attr, "int*", true, "int", 4) } */ Gui Show, w200, Test Return GuiClose: ExitApp Test: Menu, Tray, Show Return ; 暗黑托盘菜单栏函数 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) }
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)