Last active
August 6, 2019 06:10
-
-
Save jimbojetset/f6a30acb46eeff9a602639e566e7a048 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Turns the Windows 10 Taskbar transparent.