Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jimbojetset
Last active August 6, 2019 06:10
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimbojetset/f6a30acb46eeff9a602639e566e7a048 to your computer and use it in GitHub Desktop.
Save jimbojetset/f6a30acb46eeff9a602639e566e7a048 to your computer and use it in GitHub Desktop.
using System;
using System.Runtime.InteropServices;
namespace TranslucentTB
{
class Program
{
[DllImport("user32.dll")]
internal static extern IntPtr SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);
[DllImport("user32.dll")]
internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[StructLayout(LayoutKind.Sequential)]
internal struct WindowCompositionAttributeData
{
public WindowCompositionAttribute Attribute;
public IntPtr Data;
public int SizeOfData;
}
internal enum WindowCompositionAttribute
{
WCA_ACCENT_POLICY = 19
}
internal enum AccentState
{
ACCENT_DISABLED = 0,
ACCENT_ENABLE_GRADIENT = 1,
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
ACCENT_ENABLE_BLURBEHIND = 3,
ACCENT_INVALID_STATE = 4
}
[StructLayout(LayoutKind.Sequential)]
internal struct AccentPolicy
{
public AccentState AccentState;
public int AccentFlags;
public int GradientColor;
public int AnimationId;
}
static void Main(string[] args)
{
AccentPolicy accentPolicy = new AccentPolicy();
accentPolicy.AccentState = AccentState.ACCENT_ENABLE_BLURBEHIND;
accentPolicy.AccentFlags = 0;
accentPolicy.GradientColor = 0;
accentPolicy.AnimationId = 0;
IntPtr accentPtr = Marshal.AllocHGlobal(Marshal.SizeOf(accentPolicy));
Marshal.StructureToPtr(accentPolicy, accentPtr, false);
WindowCompositionAttributeData data = new WindowCompositionAttributeData();
data.Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY;
data.SizeOfData = Marshal.SizeOf(accentPolicy);
data.Data = accentPtr;
IntPtr taskbar = FindWindow("Shell_TrayWnd", null);
IntPtr secondTaskbar = FindWindow("Shell_SecondaryTrayWnd", null);
SetWindowCompositionAttribute(taskbar, ref data);
SetWindowCompositionAttribute(secondTaskbar, ref data);
}
}
}
@jimbojetset
Copy link
Author

Turns the Windows 10 Taskbar transparent.

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