. Specifically
Code: Select all
gui, +hwndhwnd
Gui, color, 000001
gui, add, button, gExt,Toggle
gui, show, w300 h200, Glass
ext()
{
static toggle:=0
global hwnd
toggle:=!toggle
WinSet,TransColor, % toggle ? "000001" : "off", % "ahk_id " hwnd
Dwm_ExtendFrameIntoClientArea(hwnd,toggle?-1:0)
return
}
Dwm_ExtendFrameIntoClientArea(hwnd,l:=0,r:=0,t=0,b:=0)
{
; Extends the window frame into the client area.
; Input:
; hwnd, unique id to the window to which to extend window frame
; l,r,t,b is left, right top and bottom margins, respectively. Use negative to create "sheet of glass"-effect
; Output:
; hresult, error msg. 0 is ok!
; Notes:
; https://msdn.microsoft.com/en-us/library/windows/desktop/aa969512(v=vs.85).aspx
; https://msdn.microsoft.com/en-us/library/windows/desktop/bb773244(v=vs.85).aspx (margins struct)
VarSetCapacity(margin,16,0)
NumPut(l,margin,0,"Int")
NumPut(r,margin,4,"Int")
NumPut(t,margin,8,"Int")
NumPut(b,margin,12,"Int")
hr:=DllCall("Dwmapi.dll\DwmExtendFrameIntoClientArea", "Uint", hwnd, "Uint", &margin)
return hr ; 0 is ok!
}
Dwm_EnableBlurBehindWindow(hwnd,onOff,x1:=0,y1:=0,x2:=0,y2:=0,fTransitionOnMaximized:=0)
{
;
; Enables the blur effect on a specified window.
; Input:
; hwnd, The handle to the window on which the blur behind data is applied.
; onOff, 1 to turn the effect on, 0 offset
; x1,...,y2, The region within the client area where the blur behind will be applied. Let be 0 to apply the blur behind on the entire client area.
; fTransitionOnMaximized, 1 if the window's colorization should transition to match the maximized windows; otherwise, 0.
; Output:
; hresult, error msg. 0 is ok!
; Url:
; https://msdn.microsoft.com/en-us/library/windows/desktop/aa969508(v=vs.85).aspx - DwmEnableBlurBehindWindow function
;
; DWM_BLURBEHIND structure:
; Url:
; https://msdn.microsoft.com/en-us/library/windows/desktop/aa969500(v=vs.85).aspx
; Create region
hrgn:=DllCall("Gdi32.dll\CreateRectRgn", "Int", x1, "Int", y1, "Int", x2, "Int", y2)
VarSetCapacity(DWM_BLURBEHIND,12+A_PtrSize,0)
NumPut(1|2|4,DWM_BLURBEHIND,0,"Uint") ; dwFlags
NumPut(onOff,DWM_BLURBEHIND,4,"Int") ; fEnable
NumPut(hrgn,DWM_BLURBEHIND,8,"Uint") ; hrgn
NumPut(fTransitionOnMaximized,DWM_BLURBEHIND,8+A_PtrSize,"Int") ; fTransitionOnMaximized
hr:= DllCall("Dwmapi.dll\DwmEnableBlurBehindWindow", "Uint", hwnd, "Uint", &DWM_BLURBEHIND)
DllCall("Gdi32.dll\DeleteObject", "Uint", hrgn) ; The region is not needed after the call.
return hr ; 0 is ok!
}
I find these functions quite awkward to work with, the blur effect is awful if you don't have transparency enabled in windows.