Advertisement
tabnation

taskbar color lib

Mar 16th, 2022
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. ;delete lines 48-55
  2.  
  3. ; ===============================================================================================================================
  4. ; Make the windows 10 taskbar translucent (blur)
  5. ; https://autohotkey.com/boards/viewtopic.php?f=6&t=26752
  6. ; ===============================================================================================================================
  7.  
  8. /*
  9. TaskBar_SetAttr(option, color)
  10. option -> 0 = off
  11. 1 = gradient (+color)
  12. 2 = transparent (+color)
  13. 3 = blur
  14. color -> ABGR (alpha | blue | green | red) 0xffd7a78f
  15. */
  16.  
  17. TaskBar_SetAttr(accent_state := 0, gradient_color := "0x01000000")
  18. {
  19. static init, hTrayWnd, ver := DllCall("GetVersion") & 0xff < 10
  20. static pad := A_PtrSize = 8 ? 4 : 0, WCA_ACCENT_POLICY := 19
  21.  
  22. if !(init) {
  23. if (ver)
  24. throw Exception("Minimum support client: Windows 10", -1)
  25. if !(hTrayWnd := DllCall("user32\FindWindow", "str", "Shell_TrayWnd", "ptr", 0, "ptr"))
  26. throw Exception("Failed to get the handle", -1)
  27. init := 1
  28. }
  29.  
  30. accent_size := VarSetCapacity(ACCENT_POLICY, 16, 0)
  31. NumPut((accent_state > 0 && accent_state < 4) ? accent_state : 0, ACCENT_POLICY, 0, "int")
  32.  
  33. if (accent_state >= 1) && (accent_state <= 2) && (RegExMatch(gradient_color, "0x[[:xdigit:]]{8}"))
  34. NumPut(gradient_color, ACCENT_POLICY, 8, "int")
  35.  
  36. VarSetCapacity(WINCOMPATTRDATA, 4 + pad + A_PtrSize + 4 + pad, 0)
  37. && NumPut(WCA_ACCENT_POLICY, WINCOMPATTRDATA, 0, "int")
  38. && NumPut(&ACCENT_POLICY, WINCOMPATTRDATA, 4 + pad, "ptr")
  39. && NumPut(accent_size, WINCOMPATTRDATA, 4 + pad + A_PtrSize, "uint")
  40. if !(DllCall("user32\SetWindowCompositionAttribute", "ptr", hTrayWnd, "ptr", &WINCOMPATTRDATA))
  41. throw Exception("Failed to set transparency / blur", -1)
  42. return true
  43. }
  44.  
  45. ; ===============================================================================================================================
  46.  
  47. /*
  48. Since clicking on Win-Start will reset the taskbar, it will be the best solution to use a SetTimer with x ms to set the Attribute
  49. #NoEnv
  50. #Persistent
  51. #SingleInstance Force
  52. SetBatchLines -1
  53. SetTimer, UPDATE_TASKBAR, 100
  54. return
  55. UPDATE_TASKBAR:
  56. TaskBar_SetAttr(3)
  57. return
  58. */
  59.  
  60.  
  61. ; ===============================================================================================================================
  62.  
  63. /*
  64. Shell_TrayWnd -> Main TaskBar
  65. Shell_SecondaryTrayWnd -> 2nd TaskBar (on multiple monitors)
  66. */
  67.  
  68. /* C++ ==========================================================================================================================
  69. BOOL GetWindowCompositionAttribute(
  70. _In_ HWND hWnd,
  71. _Inout_ WINDOWCOMPOSITIONATTRIBDATA* pAttrData
  72. );
  73. BOOL SetWindowCompositionAttribute(
  74. _In_ HWND hWnd,
  75. _Inout_ WINDOWCOMPOSITIONATTRIBDATA* pAttrData
  76. );
  77. typedef struct _WINDOWCOMPOSITIONATTRIBDATA {
  78. WINDOWCOMPOSITIONATTRIB Attrib;
  79. PVOID pvData;
  80. SIZE_T cbData;
  81. } WINDOWCOMPOSITIONATTRIBDATA;
  82. typedef enum _WINDOWCOMPOSITIONATTRIB {
  83. WCA_UNDEFINED = 0,
  84. WCA_NCRENDERING_ENABLED = 1,
  85. WCA_NCRENDERING_ENABLED = 1,
  86. WCA_NCRENDERING_POLICY = 2,
  87. WCA_TRANSITIONS_FORCEDISABLED = 3,
  88. WCA_ALLOW_NCPAINT = 4,
  89. WCA_CAPTION_BUTTON_BOUNDS = 5,
  90. WCA_NONCLIENT_RTL_LAYOUT = 6,
  91. WCA_FORCE_ICONIC_REPRESENTATION = 7,
  92. WCA_EXTENDED_FRAME_BOUNDS = 8,
  93. WCA_HAS_ICONIC_BITMAP = 9,
  94. WCA_THEME_ATTRIBUTES = 10,
  95. WCA_NCRENDERING_EXILED = 11,
  96. WCA_NCADORNMENTINFO = 12,
  97. WCA_EXCLUDED_FROM_LIVEPREVIEW = 13,
  98. WCA_VIDEO_OVERLAY_ACTIVE = 14,
  99. WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 15,
  100. WCA_DISALLOW_PEEK = 16,
  101. WCA_CLOAK = 17,
  102. WCA_CLOAKED = 18,
  103. WCA_ACCENT_POLICY = 19,
  104. WCA_FREEZE_REPRESENTATION = 20,
  105. WCA_EVER_UNCLOAKED = 21,
  106. WCA_VISUAL_OWNER = 22,
  107. WCA_LAST = 23
  108. } WINDOWCOMPOSITIONATTRIB;
  109. typedef struct _ACCENT_POLICY {
  110. ACCENT_STATE AccentState;
  111. DWORD AccentFlags;
  112. DWORD GradientColor;
  113. DWORD AnimationId;
  114. } ACCENT_POLICY;
  115. typedef enum _ACCENT_STATE {
  116. ACCENT_DISABLED = 0,
  117. ACCENT_ENABLE_GRADIENT = 1,
  118. ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
  119. ACCENT_ENABLE_BLURBEHIND = 3,
  120. ACCENT_INVALID_STATE = 4
  121. } ACCENT_STATE;
  122. _ACCENT_FLAGS {
  123. DrawLeftBorder = 0x20,
  124. DrawTopBorder = 0x40,
  125. DrawRightBorder = 0x80,
  126. DrawBottomBorder = 0x100,
  127. DrawAllBorders = (DrawLeftBorder | DrawTopBorder | DrawRightBorder | DrawBottomBorder)
  128. }
  129.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement