-
Notifications
You must be signed in to change notification settings - Fork 72
/
SetAcrylicGlassEffect.ahk
67 lines (56 loc) · 2.03 KB
/
SetAcrylicGlassEffect.ahk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
#Persistent
CreateGui()
Gui, thisGuia: Show
Return
thisGuiaGuiClose:
ExitApp
Return
thisGuiaGuiEscape:
ExitApp
Return
CreateGui() {
thisFntSize := 25
bgrColor := "000022"
txtColor := "ffeedd"
Gui, thisGuia: -DPIScale +Owner +hwndhGui
Gui, thisGuia: Margin, % thisFntSize*2, % thisFntSize*2
Gui, thisGuia: Color, c%bgrColor%
Gui, thisGuia: Font, s%thisFntSize% Q5, Arial
Gui, thisGuia: Add, Text, c%txtColor% , This is a demo. Enjoy.
WinSet, AlwaysOnTop, On, ahk_id %hGui%
SetAcrylicGlassEffect(bgrColor, 125, hGui)
}
*/
ConvertToBGRfromRGB(RGB) { ; Get numeric BGR value from numeric RGB value or HTML color name
; HEX values
BGR := SubStr(RGB, -1, 2) SubStr(RGB, 1, 4)
Return BGR
}
SetAcrylicGlassEffect(thisColor, thisAlpha, hWindow) {
; based on https://github.com/jNizM/AHK_TaskBar_SetAttr/blob/master/scr/TaskBar_SetAttr.ahk
; by jNizM
If (SafeModeExec=1 || OSDacrylicEffect=0 || thisAlpha>250)
Return
initialAlpha := thisAlpha
If (thisAlpha<16)
thisAlpha := 16
thisColor := ConvertToBGRfromRGB(thisColor)
thisAlpha := Format("{1:#x}", thisAlpha)
gradient_color := thisAlpha . thisColor
Static init, accent_state := 4, ver := DllCall("GetVersion") & 0xff < 10
Static pad := A_PtrSize = 8 ? 4 : 0, WCA_ACCENT_POLICY := 19
accent_size := VarSetCapacity(ACCENT_POLICY, 16, 0)
NumPut(accent_state, ACCENT_POLICY, 0, "int")
If (RegExMatch(gradient_color, "0x[[:xdigit:]]{8}"))
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")
If !(DllCall("user32\SetWindowCompositionAttribute", "ptr", hWindow, "ptr", &WINCOMPATTRDATA))
Return 0
thisOpacity := (initialAlpha<16) ? 60 + initialAlpha*9 : 250
WinSet, Transparent, %thisOpacity%, ahk_id %hWindow%
Return 1
}