; 自己修改了一套通用并美观的AHK界面模板,方便修改里面的控件内容后直接使用即可
; 参考至:https://www.autohotkey.com/boards/viewtopic.php?f=6&t=3851
#SingleInstance Force
SetBatchLines -1

Menu Tray, Icon, Shell32.dll, 174

Window := {Width: 530, Height: 360, Title: "Menu Interface"}  ; Version: "0.3"
Navigation := ["General", "Advanced", "Language", "Theme", "---", "Help", "About"]

Gui -Resize -MinimizeBox +HwndhGui  ; 加上-DPIScale,页面缩放比例会不正常
Gui Color, FFFFFF
Gui Add, Picture, x0 y0 w1699 h1 +0x4E +HwndhDividerLine1  ; 分割线 从左到右【顶部菜单栏】

Gui Add, Slider, w1 h1  ; 处理默认焦点虚线问题

Gui Add, Tab2, x-666 y10 w1699 h334 -Wrap +Theme -Tabstop Buttons HwndhTabControl
Gui Tab

Gui Add, Picture, x-3999 y-3999 w96 h32 vpMenuHover +0x4E +HwndhMenuHover ; 菜单悬停
Gui Add, Picture, x0 y18 w4 h32 vpMenuSelect +0x4E +HwndhMenuSelect ; 菜单选择
Gui Add, Picture, x96 y0 w1 h1340 +0x4E +HwndhDividerLine3  ; 分割线 从上到下
Gui Add, Progress, x0 y0 w96 h799 +0x4000000 +E0x4 Disabled BackgroundF7F7F7 ; 左侧常态背景色

; 左侧Tab标题的 字体大小 和 字体加粗
Gui Font, Bold c808080 Q5, Microsoft YaHei UI
Loop % Navigation.Length() {
  GuiControl,, %hTabControl%, % Navigation[A_Index] "|"
  If (Navigation[A_Index] = "---")
    Continue

  Gui Add, Text, % "x0 y" (32*A_Index)-24 " h32 w96 Center +0x200 BackgroundTrans gMenuClick vMenuItem" . A_Index, % Navigation[A_Index]
}
Gui Font

; 右侧顶部Tab标题的字体大小【可删除】
Gui Font, s15 Q5 c000000, Microsoft YaHei UI
Gui Add, Text, x117 y4 w140 h32 +0x200 vPageTitle
Gui Add, Picture, % "x110 y38 w" (Window.Width-110)-16 " h1 +0x4E +HwndhDividerLine2"  ; 分割线
Gui Font

Gui Tab, 1
Gui Font, W560, Microsoft YaHei UI
Gui Add, Text, Section x116 y50 BackgroundWhite, Select your primary button
Gui Add, DropDownList, xs+10 w80 vPrimaryButton Choose1, Left||Right
Gui Font, W560, Microsoft YaHei UI
Gui Add, Text, xs yp+40, Cursor Speed
Gui Font
Gui Add, Slider, vMySlider NoTicks, 50
Gui Font, W560, Microsoft YaHei UI
Gui Add, Text, yp+40 , Roll the mouse wheel to scrol
Gui Font
Gui Add, Radio, xs+10 yp+22 h14 Checked, Multiple lines at a time
Gui Add, Radio, xs+10 y+8 h14, On screen at a time
Gui Font, W560, Microsoft YaHei UI
Gui Add, Checkbox, xs yp+36 h14, Mouse Button Tips
Gui Font

Gui Tab, 2
Gui Add, ListView, % "x116 y50 w" (Window.Width-110)-30, Col1|Col2
LV_Add("", "ListView", "Example"), LV_ModifyCol()

Gui Tab, 3
Gui Add, MonthCal, x116 y50

Gui Tab, 4
Gui Add, DateTime, x116 y50, LongDate

Gui Tab, 5  ; Skipped

Gui Tab, 6
Gui Add, GroupBox, % "x116 y50 w" (Window.Width-110)-30, GroupBox

Gui Tab, 7
Gui Add, TreeView, x116 y50 w220 h148
P1 := TV_Add("First parent"), P1C1 := TV_Add("Parent 1's first child", P1)

Gui Show, % " w" Window.Width " h" Window.Height, % Window.Title

SetPixelColor("E9E9E9", hMenuHover)
SetPixelColor("0078D7", hMenuSelect)
Loop 4
  SetPixelColor("D8D8D8", hDividerLine%A_Index%)
SelectMenu("MenuItem1")
OnMessage(0x200, "WM_MOUSEMOVE")
Return


MenuClick:
  SelectMenu(A_GuiControl)
Return

GuiClose:
  ExitApp

WM_MOUSEMOVE(wParam, lParam, Msg, Hwnd) {
  Global hMenuSelect
  Static hover := {}

  if (wParam = "timer") {
    MouseGetPos,,,, hControl, 2
    if (hControl != hwnd) && (hControl != hMenuSelect) {
      SetTimer,, Delete
      GuiControl, Move, pMenuHover, x-9999 y-9999
      OnMessage(0x200, "WM_MOUSEMOVE")
      , hover[hwnd] := False
    }
  } else {
    if (InStr(A_GuiControl, "MenuItem") = True) {
      GuiControl, MoveDraw, pMenuHover, % "x0 y" (32*SubStr(A_GuiControl, 9, 2))-24
      hover[hwnd] := True
      , OnMessage(0x200, "WM_MOUSEMOVE", 0)
      , timer := Func(A_ThisFunc).Bind("timer", "", "", hwnd)
      SetTimer %timer%, 15
    } else if (InStr(A_GuiControl, "MenuItem") = False)
      GuiControl, Move, pMenuHover, x-9999 y-9999
  }
}

SelectMenu(Control) {
  Global
  Loop % Navigation.Length()
    SetControlColor("808080", Navigation[A_Index])  ; 左侧未选中按钮的颜色

  SetControlColor("237FFF", Control)  ; 左侧选中按钮的颜色
  GuiControl, Move, pMenuSelect, % "x0 y" (32*SubStr(Control, 9, 2))-20 " w4 h24"
  GuiControl, Choose, %hTabControl%, % SubStr(Control, 9, 2)
  GuiControl,, PageTitle, % Navigation[SubStr(Control, 9, 2)]
}

SetControlColor(Color, Control) {
  GuiControl, +c%Color%, %Control%

  ; 由于 Tab2 控件的重绘问题而需要
  GuiControlGet, ControlText,, %Control%
  GuiControlGet, ControlHandle, Hwnd, %Control%
  DllCall("SetWindowText", "Ptr", ControlHandle, "Str", ControlText)
  GuiControl, MoveDraw, %Control%
}

SetPixelColor(Color, Handle) {
  VarSetCapacity(BMBITS, 4, 0), Numput("0x" . Color, &BMBITS, 0, "UInt")
  , hBM := DllCall("Gdi32.dll\CreateBitmap", "Int", 1, "Int", 1, "UInt", 1, "UInt", 24, "Ptr", 0)
  , hBM := DllCall("User32.dll\CopyImage", "Ptr", hBM, "UInt", 0, "Int", 0, "Int", 0, "UInt", 0x2008)
  , DllCall("Gdi32.dll\SetBitmapBits", "Ptr", hBM, "UInt", 3, "Ptr", &BMBITS)
  return DllCall("User32.dll\SendMessage", "Ptr", Handle, "UInt", 0x172, "Ptr", 0, "Ptr", hBM)
}

 

【V2】魔改非标准Gui

 

声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。