TaskBar_SetAttr - translucent / blur / coloring Windows TaskBar

Post your working scripts, libraries and tools for AHK v1.1 and older
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

TaskBar_SetAttr - translucent / blur / coloring Windows TaskBar

11 Jan 2017, 09:24

TaskBar_SetAttr
Make the Windows 10 Taskbar translucent / blur / coloring

Image


Source:
TaskBar_SetAttr.ahk (GitHub)


Example:

Code: Select all

TaskBar_SetAttr(1, 0xc1e3c791)    ; <- Set gradient    with color 0xd7a78f ( rgb = 0x91c7e3 ) and alpha 0xc1

TaskBar_SetAttr(2, 0xa1e3c791)    ; <- Set transparent with color 0xd7a78f ( rgb = 0x91c7e3 ) and alpha 0xa1

TaskBar_SetAttr(2)                ; <- Set transparent

TaskBar_SetAttr(3)                ; <- Set blur

TaskBar_SetAttr(0)                ; <- Set standard value

Code: Select all

;Since clicking on Win-Start will reset the taskbar, it will be the best solution to use a SetTimer with x ms to set the Attribute

#NoEnv
#Persistent
#SingleInstance Force
SetBatchLines -1

SetTimer, UPDATE_TASKBAR, 200
return

UPDATE_TASKBAR:
    TaskBar_SetAttr(3)
return
What can be blured?:

Code: Select all

Shell_TrayWnd             -> Main TaskBar
Shell_SecondaryTrayWnd    -> 2nd  TaskBar (on multiple monitors)

Limitations:
Run only on Windows 10


Preview:
Spoiler

Contributing
- thanks to qwerty12
- thanks to AutoHotkey Community
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
guest3456
Posts: 3454
Joined: 09 Oct 2013, 10:31

Re: SetWindowBlur - Blurify (translucent) Windows TaskBar

11 Jan 2017, 10:04

should'nt it be named "SetTaskbarBlur" ?

nice work

User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: SetWindowBlur - Blurify (translucent) Windows TaskBar

11 Jan 2017, 10:11

thx & good idea... I try to figure out what can be blured too with this function, depends on this I will rename the function
updates / info will be follow in top post
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: SetWindowBlur - Blurify (translucent) Windows TaskBar

11 Jan 2017, 11:20

jNizM wrote:I try to figure out what can be blured too with this function
You can make similiar stuff with DWM. Specifically

Code: Select all

Dwmapi.dll\DwmExtendFrameIntoClientArea
Dwmapi.dll\DwmEnableBlurBehindWindow
Example code,

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!
}
Image
I find these functions quite awkward to work with, the blur effect is awful if you don't have transparency enabled in windows.
(Only tested on win7)
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: SetWindowBlur - Blurify (translucent) Windows TaskBar

12 Jan 2017, 02:02

Guest wrote:Doesn't seem to work on W7.
Tested just with win8.1 and win10

Pinkfloydd wrote:very nice function !
thank you =)

joedf wrote:Very interesting! :+1:
thank you =)

Helgef wrote:I find these functions quite awkward to work with, the blur effect is awful if you don't have transparency enabled in windows.
(Only tested on win7)
Your function does not work with win10
Gui returns white without blur / translucent effect
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: SetWindowBlur - Blurify (translucent) Windows TaskBar

12 Jan 2017, 06:04

Update:
I found out how to:
- set taskbar blur (translucent)
- set taskbar transparent
- to color taskbar
- to color transparent taskbar

Few more tests and later I update code
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: SetWindowBlur - Blurify (translucent) Windows TaskBar

12 Jan 2017, 13:27

Guest wrote:Doesn't seem to work on W7.
With Aero theme and transparency enabled on win 7, your taskbar will look like this.
jNizM wrote:Your function does not work with win10
Gui returns white without blur / translucent effect
I haven't used win10, but I think you need to have Aero theme (or an equivalent) and or transparency enabled. Window turning white is expected under some conditions, I don't really remember when though, I experimented with this a while back. As I mentioned, it's a bit awkward to work with. ;)
User avatar
davebrny
Posts: 85
Joined: 05 Dec 2016, 06:26

Re: SetWindowBlur - Blurify (translucent) Windows TaskBar

15 Jan 2017, 13:29

jNizM wrote:Update:
I found out how to:
- set taskbar blur (translucent)
- set taskbar transparent
- to color taskbar
- to color transparent taskbar

Few more tests and later I update code

nice one. i tried making the taskbar fully transparent before with Classic Shell but some of the white tray icons are hard to see if there is any white in the desktop background. maybe its a bit better when its blurred like this but some transparency options would be sweet. i have my taskbar at 50% at the moment and it still looks pretty good and the icons stand out even if there is something white in the background
Helgef
Posts: 4709
Joined: 17 Jul 2016, 01:02
Contact:

Re: SetWindowBlur - Blurify (translucent) Windows TaskBar

15 Jan 2017, 16:01

Helgef wrote:With Aero theme and transparency enabled on win 7, your taskbar will look like this.
I tested this on win10 now, and my statement above is not entirely true, it is similiar though.
jNizM wrote:Update:
I found out how to:
- set taskbar blur (translucent)
- set taskbar transparent
- to color taskbar
- to color transparent taskbar

Few more tests and later I update code
Also,

Code: Select all

gui, +hwndguiId
gui, color, 000001
gui, show, w300 h200, Glass
WinSet,TransColor, 000001, % "ahk_id " guiId
Swap hTaskBar for guiId and it blurs the gui, similar to my image a few posts up. (tested on win10)
User avatar
moefr01
Posts: 115
Joined: 25 Nov 2015, 09:01
Location: Germany

Re: SetWindowBlur - Blurify (translucent) Windows TaskBar

19 Jan 2017, 13:08

looks very nice with grayscaled desktoppicture (fully stretched)... thank you, jNizM
tested successfully on Windows 10 Pro 64Bit 1607 Build 14393.693 german
I coded a timer within, so I havn't got to reload after pressing win/find-keys:

SetTimer, Bluring, 250
Return
Bluring:
SetWindowBlur()
Return

...would be thankful for any other solution!

Nice and extraordinary: you can change the look of the frames of running apps in taskbar by switching colours (desktop-settings)
User avatar
jNizM
Posts: 3183
Joined: 30 Sep 2013, 01:33
Contact:

Re: TaskBar_SetAttr - translucent / blur / coloring Windows TaskBar

20 Jan 2017, 06:04

Update:
- new github repo
- new function
- coloring taskbar
- transparent taskbar
- colord transparent taskbar
- blured taskbar
- more examples
[AHK] v2.0.5 | [WIN] 11 Pro (Version 22H2) | [GitHub] Profile
User avatar
YOLO
Posts: 16
Joined: 17 Nov 2015, 17:17

Re: TaskBar_SetAttr - translucent / blur / coloring Windows TaskBar

12 Apr 2017, 19:52

Great work jNizM!

Is it possible for the Blur to be tinted with the stock taskbar color? I don't like a Clear Blur, and have been using Classic Shell to get the Tinted Blur effect.

Thanks!!!
Bross9132
Posts: 14
Joined: 08 Feb 2018, 09:46

Re: TaskBar_SetAttr - translucent / blur / coloring Windows TaskBar

01 Mar 2018, 11:48

Second Taskbar does not change.
YomYom
Posts: 2
Joined: 27 Mar 2017, 02:45

Re: TaskBar_SetAttr - translucent / blur / coloring Windows TaskBar

25 Feb 2021, 08:46

@jNizM : super nice and exactly the solution I was looking for, thanks.

I just have one question tho: how can you apply the color change to both taskbars when you have two screens?

I found this in the source:

Code: Select all

/*
Shell_TrayWnd             -> Main TaskBar
Shell_SecondaryTrayWnd    -> 2nd  TaskBar (on multiple monitors)
*/
But I can't figure out how or where to use Shell_SecondaryTrayWnd. The code is above my paygrade, it seems. :)

Any hint?
User avatar
joedf
Posts: 8940
Joined: 29 Sep 2013, 17:08
Location: Canada
Contact:

Re: TaskBar_SetAttr - translucent / blur / coloring Windows TaskBar

27 Feb 2021, 08:35

@YomYom
I think you can just replace it this part:
DllCall("user32\FindWindow", "str", "Shell_TrayWnd", "ptr", 0, "ptr")
:think:
Image Image Image Image Image
Windows 10 x64 Professional, Intel i5-8500, NVIDIA GTX 1060 6GB, 2x16GB Kingston FURY Beast - DDR4 3200 MHz | [About Me] | [About the AHK Foundation] | [Courses on AutoHotkey]
[ASPDM - StdLib Distribution] | [Qonsole - Quake-like console emulator] | [LibCon - Autohotkey Console Library]
10inchOfSnow
Posts: 23
Joined: 26 Jul 2019, 06:41

Re: TaskBar_SetAttr - translucent / blur / coloring Windows TaskBar

19 Apr 2021, 03:41

joedf wrote:
27 Feb 2021, 08:35
@YomYom
I think you can just replace it this part:
DllCall("user32\FindWindow", "str", "Shell_TrayWnd", "ptr", 0, "ptr")
:think:
I have 3 monitors, what should I do to change taskbar color on them all??

Return to “Scripts and Functions (v1)”

Who is online

Users browsing this forum: No registered users and 125 guests