/*
win桌面美化,AHK桌面美化的小工具找得实在是困难,我一直想将那些小工具融合到自己可以调整的AHK中,,,可是资源少
任务栏背景透明
完全透明: accent_state := 2 并且 gradient_color := "0x01000000"
结合UMP应用RoudedTB,它成功将任务栏切割了,并可以单独隐藏右下角托盘区!  希望有人可以去RoudedTB里面看看能否用AHK实现?
UMP微软商店有一个TranslucentTB结合RoudedTB可以比较完美融合,但是我就是想少用一个软件,所以大概可以少用前者了
以下代码我是抄的AutoIt的,https://www.autoitscript.com/forum/topic/188664-function-setwindowcompositionattribute-convert-c-to-autoit/
反正能满足我的需求就可以了,毕竟中文论坛里面没有找到现成能用的
*/
#SingleInstance Force
#NoEnv
#Persistent
; #NoTrayIcon
SetBatchLines -1

; PS:此函数学习研究即可,对系统变化和判断的能力不如TranslucentTB工具
SetTimer, UPDATE_TASKBAR, 100
return

UPDATE_TASKBAR:
TaskBarSet(2, 0x90191919) ; 函数默认全透明了,我就不用传参数了
return

;accent_state := 2 ; 2代表透明,我用2,1
;gradient_color := "0x01000000" ; 0x01前面四个数字代表gradient梯度,它和透明2组合之后效果就是完全透明
;2, 0xa1e3c791)    ; <- Set transparent with color 0xd7a78f ( rgb = 0x91c7e3 ) and alpha 0xa1
TaskBarSet(accent_state:=2,gradient_color:="0x01000000")
{
  hTrayWnd := DllCall("User32\FindWindow", "str", "Shell_TrayWnd", "ptr", , "ptr")  
  pad := A_PtrSize=8 ? 4 : 0
  WCA_ACCENT_POLICY := 19
  accent_size := VarSetCapacity(ACCENT_POLICY, 16, 0)
    NumPut((accent_state>0 && accent_state<4) ? accent_state : 0, ACCENT_POLICY, 0, "int")
    NumPut(gradient_color, ACCENT_POLICY, 8, "int")
    VarSetCapacity(WINCOMPATTRDATA, 4 + pad + A_PtrSize + 4 + pad, 0)
    && NumPut(WCA_ACCENT_POLICY, WINCOMPATTRDATA, 0, "int")
    && NumPut(&ACCENT_POLICY, WINCOMPATTRDATA, 4 + pad, "ptr")
    && NumPut(accent_size, WINCOMPATTRDATA, 4 + pad + A_PtrSize, "uint")
  DllCall("user32\SetWindowCompositionAttribute", "ptr", hTrayWnd, "ptr", &WINCOMPATTRDATA)
  ;就是这么一个API
}
/* 这数据结构是这样的
typedef struct _WINDOWCOMPOSITIONATTRIBDATA {
    WINDOWCOMPOSITIONATTRIB Attrib;
    PVOID                   pvData;
    SIZE_T                  cbData;
} WINDOWCOMPOSITIONATTRIBDATA;
typedef enum _WINDOWCOMPOSITIONATTRIB {
    WCA_UNDEFINED = 0,
    WCA_NCRENDERING_ENABLED = 1,
    WCA_NCRENDERING_ENABLED = 1,
    WCA_NCRENDERING_POLICY = 2,
    WCA_TRANSITIONS_FORCEDISABLED = 3,
    WCA_ALLOW_NCPAINT = 4,
    WCA_CAPTION_BUTTON_BOUNDS = 5,
    WCA_NONCLIENT_RTL_LAYOUT = 6,
    WCA_FORCE_ICONIC_REPRESENTATION = 7,
    WCA_EXTENDED_FRAME_BOUNDS = 8,
    WCA_HAS_ICONIC_BITMAP = 9,
    WCA_THEME_ATTRIBUTES = 10,
    WCA_NCRENDERING_EXILED = 11,
    WCA_NCADORNMENTINFO = 12,
    WCA_EXCLUDED_FROM_LIVEPREVIEW = 13,
    WCA_VIDEO_OVERLAY_ACTIVE = 14,
    WCA_FORCE_ACTIVEWINDOW_APPEARANCE = 15,
    WCA_DISALLOW_PEEK = 16,
    WCA_CLOAK = 17,
    WCA_CLOAKED = 18,
    WCA_ACCENT_POLICY = 19,
    WCA_FREEZE_REPRESENTATION = 20,
    WCA_EVER_UNCLOAKED = 21,
    WCA_VISUAL_OWNER = 22,
    WCA_LAST = 23
} WINDOWCOMPOSITIONATTRIB;
typedef struct _ACCENT_POLICY {
    ACCENT_STATE AccentState;
    DWORD        AccentFlags;
    DWORD        GradientColor;
    DWORD        AnimationId;
} ACCENT_POLICY;
typedef enum _ACCENT_STATE {
    ACCENT_DISABLED = 0,
    ACCENT_ENABLE_GRADIENT = 1,
    ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
    ACCENT_ENABLE_BLURBEHIND = 3,
    ACCENT_INVALID_STATE = 4
} ACCENT_STATE;
_ACCENT_FLAGS {
    DrawLeftBorder = 0x20,
    DrawTopBorder = 0x40,
    DrawRightBorder = 0x80,
    DrawBottomBorder = 0x100,
    DrawAllBorders = (DrawLeftBorder | DrawTopBorder | DrawRightBorder | DrawBottomBorder)
}
*/

 

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