Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#include <windows.h>
void SetWindowBlur(HWND hWnd)
{
const HINSTANCE hModule = LoadLibrary(TEXT("user32.dll"));
if (hModule)
{
struct ACCENTPOLICY
{
int nAccentState;
int nFlags;
int nColor;
int nAnimationId;
};
struct WINCOMPATTRDATA
{
int nAttribute;
PVOID pData;
ULONG ulDataSize;
};
typedef BOOL(WINAPI*pSetWindowCompositionAttribute)(HWND, WINCOMPATTRDATA*);
const pSetWindowCompositionAttribute SetWindowCompositionAttribute = (pSetWindowCompositionAttribute)GetProcAddress(hModule, "SetWindowCompositionAttribute");
if (SetWindowCompositionAttribute)
{
ACCENTPOLICY policy = { 3, 0, 0, 0 }; // ACCENT_ENABLE_BLURBEHIND=3...
WINCOMPATTRDATA data = { 19, &policy, sizeof(ACCENTPOLICY) }; // WCA_ACCENT_POLICY=19
SetWindowCompositionAttribute(hWnd, &data);
}
FreeLibrary(hModule);
}
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPreInst, LPSTR pCmdLine, int nCmdShow)
{
HWND taskbar = FindWindow(L"Shell_TrayWnd", NULL);
while (true) {
SetWindowBlur(taskbar); Sleep((DWORD)10);
}
}
@AchoArnold

This comment has been minimized.

Show comment Hide comment
@AchoArnold

AchoArnold Jan 9, 2017

Awesome 👍

Awesome 👍

@grebnetiew

This comment has been minimized.

Show comment Hide comment
@grebnetiew

grebnetiew Jan 9, 2017

Cool! I'm a beginner at Windows programming, so I have a few questions ;)
Could you elaborate on why you have to re-run SetWindowBlur every 10 ms? Is there some mechanism that resets the taskbar window very often?
Also, I would have done most of the setup in your SetWindowBlur in WinMain (i.e. only once), and then only called SetWindowCompositionAttribute every 10 ms. Is there a reason that you load and unload the library every time you want to re-apply the composition attributes?
Thanks for your time and the very nice tweak, in any case :)

Cool! I'm a beginner at Windows programming, so I have a few questions ;)
Could you elaborate on why you have to re-run SetWindowBlur every 10 ms? Is there some mechanism that resets the taskbar window very often?
Also, I would have done most of the setup in your SetWindowBlur in WinMain (i.e. only once), and then only called SetWindowCompositionAttribute every 10 ms. Is there a reason that you load and unload the library every time you want to re-apply the composition attributes?
Thanks for your time and the very nice tweak, in any case :)

@akashmishra23

This comment has been minimized.

Show comment Hide comment
@akashmishra23

akashmishra23 Jan 9, 2017

You're da Real MVP...

You're da Real MVP...

@sadphi

This comment has been minimized.

Show comment Hide comment
@sadphi

sadphi Jan 9, 2017

@grebnetiew It needs to refresh every 10 ms as opening the start button will make the blur go away.

Also, At line 40, is the L a mistype? It works without the L and it only gives errors.

sadphi commented Jan 9, 2017

@grebnetiew It needs to refresh every 10 ms as opening the start button will make the blur go away.

Also, At line 40, is the L a mistype? It works without the L and it only gives errors.

@grebnetiew

This comment has been minimized.

Show comment Hide comment
@grebnetiew

grebnetiew Jan 9, 2017

Ah I see. Thanks :)

Ah I see. Thanks :)

@morganrpugh

This comment has been minimized.

Show comment Hide comment
@embql

This comment has been minimized.

Show comment Hide comment
@embql

embql Jan 10, 2017

Downloading your compiled exe from a link to your Google Drive reveals that it is infected with "Gen:Variant.Razy.110665".
What gives? Both Google and my own protection software catches it.

embql commented Jan 10, 2017

Downloading your compiled exe from a link to your Google Drive reveals that it is infected with "Gen:Variant.Razy.110665".
What gives? Both Google and my own protection software catches it.

@denosawr

This comment has been minimized.

Show comment Hide comment
@denosawr

denosawr Jan 10, 2017

Probably a stupid question (I have pretty much no C++ experience), but why does your compiled exe make the taskbar completely transparent (and this code doesn't)? Also your image on Reddit shows a translucent taskbar, not a transparent one.

Probably a stupid question (I have pretty much no C++ experience), but why does your compiled exe make the taskbar completely transparent (and this code doesn't)? Also your image on Reddit shows a translucent taskbar, not a transparent one.

@jNizM

This comment has been minimized.

Show comment Hide comment
@Eweol

This comment has been minimized.

Show comment Hide comment
@Eweol

Eweol Jan 10, 2017

Is there a Chance to get the transparent taskbar on more than one monitor?

Eweol commented Jan 10, 2017

Is there a Chance to get the transparent taskbar on more than one monitor?

@sadphi

This comment has been minimized.

Show comment Hide comment
@sadphi

sadphi Jan 10, 2017

@morganrpugh I see, thanks

sadphi commented Jan 10, 2017

@morganrpugh I see, thanks

@jNizM

This comment has been minimized.

Show comment Hide comment
@jNizM

jNizM Jan 11, 2017

@Eweol For this information, follow my link I posted above =)

jNizM commented Jan 11, 2017

@Eweol For this information, follow my link I posted above =)

@link6155

This comment has been minimized.

Show comment Hide comment
@link6155

link6155 Jan 11, 2017

@jNizM I compiled your autohotkey script and it works for a few seconds before the script appears to crash.

@jNizM I compiled your autohotkey script and it works for a few seconds before the script appears to crash.

@wbalbinot

This comment has been minimized.

Show comment Hide comment
@wbalbinot

wbalbinot Jan 11, 2017

Waiting for the v2 :D

Waiting for the v2 :D

@marklk

This comment has been minimized.

Show comment Hide comment
@marklk

marklk Jan 13, 2017

So just exactly how would i instal this code? Does it come in a executable version?

marklk commented Jan 13, 2017

So just exactly how would i instal this code? Does it come in a executable version?

@ethanhs

This comment has been minimized.

Show comment Hide comment
@ethanhs

ethanhs Jun 3, 2017

A lot has happened since this was published. Please see https://github.com/TranslucentTB/TranslucentTB/ for more.

Owner

ethanhs commented Jun 3, 2017

A lot has happened since this was published. Please see https://github.com/TranslucentTB/TranslucentTB/ for more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment