E1M1 Posted February 3, 2021 Share Posted February 3, 2021 (edited) Hi! I have script that blurs GUI on window 10. But button and input are unusable. In other words I want text to be black on them. How do I fix it? expandcollapse popup#include <GUIConstants.au3> #include <WinAPI.au3> #include <WinAPIGdi.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> If _WinAPI_DwmIsCompositionEnabled() Then $iHasDWM=1 Local $iHeight=300 Local $iWidth=300 $hGUI = GUICreate("Windows 10 Blur", $iWidth, $iHeight,-1,-1) GUICtrlCreateButton("test", 10,10, 75, 25) GUICtrlCreateInput("test", 10,40, 75, 25) GUISetBkColor(0x000000) GUISetState() If $iHasDWM Then Local $hRgn = _WinAPI_CreateRoundRectRgn(0,0,$iWidth+1,$iHeight+1,50,50) Local $hFormRgn=_WinAPI_CreateRectRgnIndirect(_WinAPI_GetClientRect($hGUI)) Local $hRgnTest=_WinAPI_CreateNullRgn() _WinAPI_CombineRgn($hRgnTest,$hRgn,$hFormRgn,$RGN_XOR) _WinAPI_DwmEnableBlurBehindWindow($hGUI,1,1,$hRgnTest) _WinAPI_DwmEnableBlurBehindWindow10($hGUI) EndIf While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_DwmEnableBlurBehindWindow10 ; Description ...: Enables Aero-like blurred background in Windows 10. ; Syntax ........: _WinAPI_DwmEnableBlurBehindWindow10($hWnd[, $iMode = $ACCENT_ENABLE_BLURBEHIND]) ; Parameters ....: $hWnd - Window handle. ; $bEnable - [optional] Enable or disable the blur effect. ; Return values .: 1 on success, 0 otherwise. Call _WinAPI_GetLastError on failure for more information. ; Author ........: scintilla4evr ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: http://vhanla.codigobit.info/2015/07/enable-windows-10-aero-glass-aka-blur.html and http://undoc.airesoft.co.uk/user32.dll/SetWindowCompositionAttribute.php ; Example .......: Yes ; =============================================================================================================================== Func _WinAPI_DwmEnableBlurBehindWindow10($hWnd, $bEnable = True) Local $tAccentPolicy = DllStructCreate("int AccentState; int AccentFlags; int GradientColor; int AnimationId") Local $tAttrData = DllStructCreate("dword Attribute; ptr DataBuffer; ulong Size") $tAccentPolicy.AccentState = $bEnable ? 3 : 0 $tAttrData.Attribute = 19 ; WCA_ACCENT_POLICY $tAttrData.DataBuffer = DllStructGetPtr($tAccentPolicy) $tAttrData.Size = DllStructGetSize($tAccentPolicy) Local $aResult = DllCall("user32.dll", "bool", "SetWindowCompositionAttribute", "hwnd", $hWnd, "ptr", DllStructGetPtr($tAttrData)) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Edited February 3, 2021 by E1M1 edited Link to comment Share on other sites More sharing options...
Sidley Posted February 3, 2021 Share Posted February 3, 2021 (edited) See below. No idea if you can set the background colour to make it readable. expandcollapse popup#include <GUIConstants.au3> #include <WinAPI.au3> #include <WinAPIGdi.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> If _WinAPI_DwmIsCompositionEnabled() Then $iHasDWM=1 Local $iHeight=300 Local $iWidth=300 $hGUI = GUICreate("Windows 10 Blur", $iWidth, $iHeight,-1,-1) Local $idButton1 = GUICtrlCreateButton("test", 10,10, 75, 25) ;Assign button to id variable Local $idInput1 = GUICtrlCreateInput("test", 10,40, 75, 25) GUISetBkColor(0x000000) GUISetState() If $iHasDWM Then Local $hRgn = _WinAPI_CreateRoundRectRgn(0,0,$iWidth+1,$iHeight+1,50,50) Local $hFormRgn=_WinAPI_CreateRectRgnIndirect(_WinAPI_GetClientRect($hGUI)) Local $hRgnTest=_WinAPI_CreateNullRgn() _WinAPI_CombineRgn($hRgnTest,$hRgn,$hFormRgn,$RGN_XOR) _WinAPI_DwmEnableBlurBehindWindow($hGUI,1,1,$hRgnTest) _WinAPI_DwmEnableBlurBehindWindow10($hGUI) EndIf Local $sText = "" While 1 Local $idMsg = GUIGetMsg() ;Assign GUIGetMsg() result to variable Switch $idMsg Case $GUI_EVENT_CLOSE ExitLoop Case $idButton1 ;If GUI Msg received = button id $sText = GUICtrlRead($idInput1) MsgBox($MB_SYSTEMMODAL, "", "Text is: " & $sText) ;Action here EndSwitch WEnd ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_DwmEnableBlurBehindWindow10 ; Description ...: Enables Aero-like blurred background in Windows 10. ; Syntax ........: _WinAPI_DwmEnableBlurBehindWindow10($hWnd[, $iMode = $ACCENT_ENABLE_BLURBEHIND]) ; Parameters ....: $hWnd - Window handle. ; $bEnable - [optional] Enable or disable the blur effect. ; Return values .: 1 on success, 0 otherwise. Call _WinAPI_GetLastError on failure for more information. ; Author ........: scintilla4evr ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: http://vhanla.codigobit.info/2015/07/enable-windows-10-aero-glass-aka-blur.html and http://undoc.airesoft.co.uk/user32.dll/SetWindowCompositionAttribute.php ; Example .......: Yes ; =============================================================================================================================== Func _WinAPI_DwmEnableBlurBehindWindow10($hWnd, $bEnable = True) Local $tAccentPolicy = DllStructCreate("int AccentState; int AccentFlags; int GradientColor; int AnimationId") Local $tAttrData = DllStructCreate("dword Attribute; ptr DataBuffer; ulong Size") $tAccentPolicy.AccentState = $bEnable ? 3 : 0 $tAttrData.Attribute = 19 ; WCA_ACCENT_POLICY $tAttrData.DataBuffer = DllStructGetPtr($tAccentPolicy) $tAttrData.Size = DllStructGetSize($tAccentPolicy) Local $aResult = DllCall("user32.dll", "bool", "SetWindowCompositionAttribute", "hwnd", $hWnd, "ptr", DllStructGetPtr($tAttrData)) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Edited February 3, 2021 by Sidley Link to comment Share on other sites More sharing options...
E1M1 Posted February 3, 2021 Author Share Posted February 3, 2021 Hi, sorry I wasn't clear enough. Yes, the problem was their background color, not clicking on them. As this thing removes black. by unusable I meant that input has no real use if it is white on white. Would like to keep black as text color. edited Link to comment Share on other sites More sharing options...
Sidley Posted February 3, 2021 Share Posted February 3, 2021 That seems to be correct, lloks like black is used as the mask colour for the blur/transparency so the closer the item colour gets to black the more transparent it is. White works well but obviously over a dark background. I've had a play about with the settings but I can't see any way of changing the mask colour. Link to comment Share on other sites More sharing options...
UEZ Posted February 3, 2021 Share Posted February 3, 2021 You can use this to get the blurry effect on dark background with readable fonts. expandcollapse popup#include <GUIConstants.au3> #include <WinAPI.au3> #include <WinAPIGdi.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> If _WinAPI_DwmIsCompositionEnabled() Then $iHasDWM=1 Local $iHeight=300 Local $iWidth=300 $hGUI = GUICreate("Windows 10 Blur", $iWidth, $iHeight,-1,-1) GUICtrlCreateButton("test", 10,10, 75, 25) GUICtrlSetColor(-1, 0) GUICtrlSetFont(-1, 9, 800, 0, "Arial") GUICtrlCreateInput("test", 10,40, 75, 25) GUISetBkColor(0) GUICtrlSetFont(-1, 9, 800, 0, "Arial") GUISetState() If $iHasDWM Then ;~ Local $hRgn = _WinAPI_CreateRoundRectRgn(0,0,$iWidth+1,$iHeight+1,50,50) ;~ Local $hFormRgn=_WinAPI_CreateRectRgnIndirect(_WinAPI_GetClientRect($hGUI)) Local $hRgnTest=_WinAPI_CreateNullRgn() ;~ _WinAPI_CombineRgn($hRgnTest,$hRgn,$hFormRgn,$RGN_OR) _WinAPI_DwmEnableBlurBehindWindow($hGUI,1,1,$hRgnTest) _WinAPI_DwmEnableBlurBehindWindow10($hGUI) EndIf While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE _WinAPI_DeleteObject($hRgnTest) ExitLoop EndSwitch WEnd ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_DwmEnableBlurBehindWindow10 ; Description ...: Enables Aero-like blurred background in Windows 10. ; Syntax ........: _WinAPI_DwmEnableBlurBehindWindow10($hWnd[, $iMode = $ACCENT_ENABLE_BLURBEHIND]) ; Parameters ....: $hWnd - Window handle. ; $bEnable - [optional] Enable or disable the blur effect. ; Return values .: 1 on success, 0 otherwise. Call _WinAPI_GetLastError on failure for more information. ; Author ........: scintilla4evr ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: http://vhanla.codigobit.info/2015/07/enable-windows-10-aero-glass-aka-blur.html and http://undoc.airesoft.co.uk/user32.dll/SetWindowCompositionAttribute.php ; Example .......: Yes ; =============================================================================================================================== Func _WinAPI_DwmEnableBlurBehindWindow10($hWnd, $bEnable = True) Local $tAccentPolicy = DllStructCreate("int AccentState; int AccentFlags; int GradientColor; int AnimationId") Local $tAttrData = DllStructCreate("dword Attribute; ptr DataBuffer; ulong Size") $tAccentPolicy.AccentState = $bEnable ? 3 : 0 $tAttrData.Attribute = 19 ; WCA_ACCENT_POLICY $tAttrData.DataBuffer = DllStructGetPtr($tAccentPolicy) $tAttrData.Size = DllStructGetSize($tAccentPolicy) Local $aResult = DllCall("user32.dll", "bool", "SetWindowCompositionAttribute", "hwnd", $hWnd, "ptr", DllStructGetPtr($tAttrData)) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
E1M1 Posted February 4, 2021 Author Share Posted February 4, 2021 Is there any way to get it work with white background? I tried to play around with CombineRgn in hope that I could somehow just exclude the buttons and other controls from blur so that they would be displayed normally, but it did not seem to work. I also tried to put them in child window but once I gave it $WS_C_HILD and set parent the child also inherited blur. I am looking to have something like win 10 calculator app that has blur but also black text on buttons. edited Link to comment Share on other sites More sharing options...
UEZ Posted February 4, 2021 Share Posted February 4, 2021 This code look like this on my Win10 system: expandcollapse popup#include <GUIConstants.au3> #include <WinAPI.au3> #include <WinAPIGdi.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> If _WinAPI_DwmIsCompositionEnabled() Then $iHasDWM=1 $iWidth=314 $iHeight=140 #Region ### START Koda GUI section ### Form= $hGUI = GUICreate("Test", $iWidth, $iHeight) GUISetFont(10, 600, 0, "Arial", $hGUI) $Button1 = GUICtrlCreateButton("=", 232, 104, 75, 25, -1) $Button2 = GUICtrlCreateButton("+", 232, 80, 75, 25) $Button3 = GUICtrlCreateButton("-", 232, 56, 75, 25) $Button4 = GUICtrlCreateButton("*", 232, 32, 75, 25) $Button5 = GUICtrlCreateButton("/", 232, 8, 75, 25) $Button6 = GUICtrlCreateButton(",", 152, 104, 75, 25) $Button7 = GUICtrlCreateButton("0", 80, 104, 75, 25) $Button8 = GUICtrlCreateButton("+/-", 8, 104, 75, 25) $Button9 = GUICtrlCreateButton("1", 8, 80, 75, 25) $Button10 = GUICtrlCreateButton("2", 80, 80, 75, 25) $Button11 = GUICtrlCreateButton("3", 152, 80, 75, 25) $Button12 = GUICtrlCreateButton("6", 152, 56, 75, 25) $Button13 = GUICtrlCreateButton("5", 80, 56, 75, 25) $Button14 = GUICtrlCreateButton("4", 8, 56, 75, 25) $Button15 = GUICtrlCreateButton("7", 8, 32, 75, 25) $Button16 = GUICtrlCreateButton("8", 80, 32, 75, 25) $Button17 = GUICtrlCreateButton("9", 152, 32, 75, 25) $Input1 = GUICtrlCreateInput("Input / Output", 8, 8, 218, 21) GUISetBkColor(0x808080) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### If $iHasDWM Then _WinAPI_DwmEnableBlurBehindWindow($hGUI) _WinAPI_DwmEnableBlurBehindWindow10($hGUI) EndIf While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WinAPI_DwmEnableBlurBehindWindow10 ; Description ...: Enables Aero-like blurred background in Windows 10. ; Syntax ........: _WinAPI_DwmEnableBlurBehindWindow10($hWnd[, $iMode = $ACCENT_ENABLE_BLURBEHIND]) ; Parameters ....: $hWnd - Window handle. ; $bEnable - [optional] Enable or disable the blur effect. ; Return values .: 1 on success, 0 otherwise. Call _WinAPI_GetLastError on failure for more information. ; Author ........: scintilla4evr ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: http://vhanla.codigobit.info/2015/07/enable-windows-10-aero-glass-aka-blur.html and http://undoc.airesoft.co.uk/user32.dll/SetWindowCompositionAttribute.php ; Example .......: Yes ; =============================================================================================================================== Func _WinAPI_DwmEnableBlurBehindWindow10($hWnd, $bEnable = True) Local $tAccentPolicy = DllStructCreate("int AccentState; int AccentFlags; int GradientColor; int AnimationId") Local $tAttrData = DllStructCreate("dword Attribute; ptr DataBuffer; ulong Size") $tAccentPolicy.AccentState = $bEnable ? 3 : 0 $tAttrData.Attribute = 19 ; WCA_ACCENT_POLICY $tAttrData.DataBuffer = DllStructGetPtr($tAccentPolicy) $tAttrData.Size = DllStructGetSize($tAccentPolicy) Local $aResult = DllCall("user32.dll", "bool", "SetWindowCompositionAttribute", "hwnd", $hWnd, "struct*", $tAttrData) If @error Then Return SetError(@error, @extended, 0) Return $aResult[0] EndFunc E1M1 1 Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
E1M1 Posted February 11, 2021 Author Share Posted February 11, 2021 It is good that you added screenshot. Yes it is exactly what I was looking for. On my work and home computers both it displays like this: I am not sure what is wrong. edited Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now