Aero Glass blur to your Windows 10 Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
User avatar
F4Jonatas
Posts: 45
Joined: 22 Oct 2015, 06:35
Contact:

Aero Glass blur to your Windows 10

09 Jun 2016, 10:09

Hello everybody!
I'm a big fan of AHK and also Windows.

So I learned to create GUI's with Aero Glass in Windows 7, I started using Windows 8. Now Aero Glass is back in Windows 10, but do not know how to use Aero Glass...
Then I found this site:
http://withinrafael.com/adding-the-aero ... s-10-apps/
And I was wondering if you can turn this code to AHK_L?

Thank you all!
qwerty12
Posts: 468
Joined: 04 Mar 2016, 04:33
Contact:

Re: Aero Glass blur to your Windows 10  Topic is solved

09 Jun 2016, 14:33

EDIT: Thanks to jNizM for heavily fixing this one up below

Hi,

I know nothing about AHK GUIs so this is as far I go:

Code: Select all

EnableBlur(gHwnd)
{
    ; WindowCompositionAttribute
    WCA_ACCENT_POLICY := 19
    
    ; AccentState
    ACCENT_DISABLED := 0,
    ACCENT_ENABLE_GRADIENT := 1,
    ACCENT_ENABLE_TRANSPARENTGRADIENT := 2
    ACCENT_ENABLE_BLURBEHIND := 3
    ACCENT_INVALID_STATE := 4

    accentStructSize := VarSetCapacity(AccentPolicy, 4*4, 0)
    NumPut(ACCENT_ENABLE_BLURBEHIND, AccentPolicy, 0, "UInt")

    padding := A_PtrSize == 8 ? 4 : 0
    VarSetCapacity(WindowCompositionAttributeData, 4 + padding + A_PtrSize + 4 + padding)
    NumPut(WCA_ACCENT_POLICY, WindowCompositionAttributeData, 0, "UInt")
    NumPut(&AccentPolicy, WindowCompositionAttributeData, 4 + padding, "Ptr")
    NumPut(accentStructSize, WindowCompositionAttributeData, 4 + padding + A_PtrSize, "UInt")
    
    DllCall("SetWindowCompositionAttribute", "Ptr", gHwnd, "Ptr", &WindowCompositionAttributeData)
}


Gui +LastFound -Caption +Border +hwndgHwnd
Gui, Color, 000000
WinSet, TransColor, 000000
Gui, Font, s64, Segoe UI
Gui, Add, Text, x0 y200 w500 Center cWhite, Hello Blur!
Gui, Show, w500 h500 Center
EnableBlur(gHwnd)
Last edited by qwerty12 on 10 Jun 2016, 03:40, edited 1 time in total.
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: Aero Glass blur to your Windows 10

10 Jun 2016, 01:17

thx qwerty12, something to play with
too bad that the font brakes with gui caption on
(edit: small fix for caption on is adding q3 on gui font [Gui, Font, s64 q3, Segoe UI] - not beautiful but better than nothing)

added WM_LBUTTONDOWN to move the gui

Code: Select all

OnMessage(0x0201, "WM_LBUTTONDOWN")

; ===============================================================================================================================

Gui +LastFound -Caption +Border +hWndhMain
Gui, Color, 000000
WinSet, TransColor, 000000
Gui, Font, s64, Segoe UI
Gui, Add, Text, x0 y200 w500 Center cWhite, Hello Blur!
Gui, Show, w500 h500 Center
EnableBlur(hMain)
return

GuiEscape:
ExitApp

; ===============================================================================================================================

WM_LBUTTONDOWN(wParam, lParam, msg, hWnd)
{
    global hMain
    if (hWnd = hMain)
		DllCall("user32.dll\PostMessage", "Ptr", hWnd, "UInt", 0xA1, "Ptr", 2, "Ptr", 0)
}

EnableBlur(hWnd)
{
    ; WindowCompositionAttribute
    WCA_ACCENT_POLICY := 19
 
    ; AccentState
    ACCENT_DISABLED := 0,
    ACCENT_ENABLE_GRADIENT := 1,
    ACCENT_ENABLE_TRANSPARENTGRADIENT := 2
    ACCENT_ENABLE_BLURBEHIND := 3
    ACCENT_INVALID_STATE := 4
 
    accentStructSize := VarSetCapacity(AccentPolicy, 4*4, 0)
    NumPut(ACCENT_ENABLE_BLURBEHIND, AccentPolicy, 0, "UInt")
 
    padding := A_PtrSize == 8 ? 4 : 0
    VarSetCapacity(WindowCompositionAttributeData, 4 + padding + A_PtrSize + 4 + padding)
    NumPut(WCA_ACCENT_POLICY, WindowCompositionAttributeData, 0, "UInt")
    NumPut(&AccentPolicy, WindowCompositionAttributeData, 4 + padding, "Ptr")
    NumPut(accentStructSize, WindowCompositionAttributeData, 4 + padding + A_PtrSize, "UInt")
 
    DllCall("SetWindowCompositionAttribute", "Ptr", hWnd, "Ptr", &WindowCompositionAttributeData)
}
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
F4Jonatas
Posts: 45
Joined: 22 Oct 2015, 06:35
Contact:

Re: Aero Glass blur to your Windows 10

10 Jun 2016, 05:19

That's exactly What I wanted. :clap:

I need to learn about "NumPut" and "VarSetCapacity"...

I hope this helps everyone.

Thank you man!


____________________________
Advanced Teste:
[indent=1]Built in: Sublime Text (3114)
OS Version: Win 10 Pro x64 (10.0.10586)
AHK Version:[/indent][indent=2]AHK_L x64 Unicode (1.1.24.00)
AHK_L x86 Unicode (1.1.24.00)
AHK_L x86 ANSI (1.1.24.00)[/indent]

Code: Select all

OnMessage( 513, "Functions" ) ; WM_LButtonDown
OnMessage( 131, "Functions" ) ; WM_NCCalcSize
OnMessage( 132, "Functions" ) ; WM_NCHitTest
OnMessage( 134, "Functions" ) ; WM_NCActivate

Gui +LastFound +Resize +hWndhMain
Gui, Color, Black
WinSet, TransColor, Black, 1

Gui, Font, S64, Segoe UI
Gui, Add, Text, X0 Y200 W500 Center CWhite, Hello Blur!
Gui, Show, W500 H500 Center

EnableBlur( hMain )
Return

GuiEscape:
	ExitApp



Functions( wParam, lParam, msg, hWnd ) {
	Local _L := {}
	, BorderSpacing := 6
	, SizeCapacity, WinX, WinY, WinW, WinH, nil

	If ( msg == 513 ) {
		DllCall( "User32.dll\PostMessage", "Ptr", hWnd, "UInt", 0xA1, "Ptr", 2, "Ptr", 0 )
	}

	Else If ( msg == 131 ) {
		Return 0
	}

	Else If ( msg == 134 ) {
		Return 1
	}

	Else If ( msg == 132 ) {
		VarSetCapacity( SizeCapacity, 1, 0 )
		WinGetPos, WinX, WinY, WinW, WinH

		_L.Left := (( _L.X := lParam & 65535 ) < WinX + BorderSpacing )
		_L.Right := ( _L.X >= WinX + WinW - BorderSpacing )
		_L.Top := (( _L.Y := lParam >> 16 ) < WinY + BorderSpacing )
		_L.Bottom := ( _L.Y >= WinY + WinH - BorderSpacing )

		If ( _L.Top ) {
			If ( _L.Left == 1 )
				Return 13
			Else If ( _L.Right == 1 )
				Return 14
			Else Return 12
		}

		Else If ( _L.Bottom ) {
			If ( _L.Left == 1 )
				Return 16
			Else If ( _L.Right == 1 )
				Return 17
			Else Return 15
		}

		Else If ( _L.Left == 1 )
			Return 10
		Else If ( _L.Right == 1 )
			Return 11

		DllCall( "Dwmapi.dll\DwmDefWindowProc", "UInt", hWnd, "UInt", msg, "UInt", wParam, "UInt", lParam, "UInt", &SizeCapacity )
		nil := NumGet( SizeCapacity )
		Return ( nil = 0 ? "" : nil )
	}
}

EnableBlur( hWnd ) {
	Local WindowCompositionAttributeData
	, AccentPolicy

	; WindowCompositionAttribute
	Local WCA_ACCENT_POLICY := 19

	; AccentState
	Local ACCENT_DISABLED := 0
	, ACCENT_ENABLE_GRADIENT := 1
	, ACCENT_ENABLE_TRANSPARENTGRADIENT := 2
	, ACCENT_ENABLE_BLURBEHIND := 3
	, ACCENT_INVALID_STATE := 4

	Local accentStructSize := VarSetCapacity( AccentPolicy, 4 * 4, 0 )
	NumPut( ACCENT_ENABLE_BLURBEHIND, AccentPolicy, 0, "UInt" )

	Local padding := ( A_PtrSize == 8 ? 4 : 0 )
	VarSetCapacity( WindowCompositionAttributeData, 4 + padding + A_PtrSize + 4 + padding )
	NumPut( WCA_ACCENT_POLICY, WindowCompositionAttributeData, 0, "UInt" )
	NumPut( &AccentPolicy, WindowCompositionAttributeData, 4 + padding, "Ptr" )
	NumPut( accentStructSize, WindowCompositionAttributeData, 4 + padding + A_PtrSize, "UInt" )

	DllCall( "User32.dll\SetWindowCompositionAttribute", "Ptr", hWnd, "Ptr", &WindowCompositionAttributeData )
}

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: fiaztv1, JKJadan, Pianist and 174 guests