现代毛玻璃Gui.ahk
; 感觉难以应用到实际 ; https://www.autohotkey.com/boards/viewtopic.php?p=384579#p384579 #NoEnv #Persistent SetBatchLines -1 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. ; Lexikos: Add an Edit to demonstrate TransColor. Gui, thisGuia: Add, Edit,, This is a demo. Enjoy. ; Lexikos: Enable DHW so WinSet will actually work. dhw := A_DetectHiddenWindows DetectHiddenWindows On ; </Lexikos> WinSet, AlwaysOnTop, On, ahk_id %hGui% SetAcrylicGlassEffect(bgrColor, 125, hGui) DetectHiddenWindows % dhw ; Lexikos Gui, thisGuia: Show Return SetAcrylicGlassEffect(thisColor, thisAlpha, hWindow) { ; based on https://github.com/jNizM/AHK_TaskBar_SetAttr/blob/master/scr/TaskBar_SetAttr.ahk ; by jNizM initialAlpha := thisAlpha If (thisAlpha<16) thisAlpha := 16 Else If (thisAlpha>245) thisAlpha := 245 ; Lexikos: Keep original value of thisAlpha for use below. gradient_color := Format("{1:#x}{}", thisAlpha, ConvertToBGRfromRGB(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 ; Lexikos: Use TransColor instead of Transparent. WinSet, TransColor, %thisColor% %thisOpacity%, ahk_id %hWindow% Return 1 } 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 } thisGuiaGuiClose: ExitApp Return thisGuiaGuiEscape: ExitApp Return
声明:站内资源为整理优化好的代码上传分享与学习研究,如果是开源代码基本都会标明出处,方便大家扩展学习路径。请不要恶意搬运,破坏站长辛苦整理维护的劳动成果。本站为爱好者分享站点,所有内容不作为商业行为。如若本站上传内容侵犯了原著者的合法权益,请联系我们进行删除下架。
评论(0)