Skip to content

Instantly share code, notes, and snippets.

@ADeltaX
Last active April 2, 2020 14:49
Show Gist options
  • Save ADeltaX/ac8b0cab303b063f9accf6b3c0c2e60e to your computer and use it in GitHub Desktop.
Save ADeltaX/ac8b0cab303b063f9accf6b3c0c2e60e to your computer and use it in GitHub Desktop.
Hacky way to disable edge swipes (to restore them --> restart explorer.exe process)
using System;
using System.Runtime.InteropServices;
namespace ShutUpEdgeUI
{
class Program
{
[DllImport("user32.dll")]
public static extern bool GetClientRect(IntPtr hwnd, ref Rect rectangle);
[DllImport("user32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern bool PostMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", SetLastError = true)]
internal static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
public struct Rect
{
public int Left;
public int Top;
public int Right;
public int Bottom;
}
public static bool FindEdgeUIANDKILLIT()
{
IntPtr hWndHost = IntPtr.Zero;
while ((hWndHost = FindWindowEx(IntPtr.Zero, hWndHost, "EdgeUiInputWndClass", null)) != IntPtr.Zero)
{
var REKT = new Rect();
GetClientRect(hWndHost, ref REKT);
if ((REKT.Right - REKT.Left == 0 && REKT.Bottom - REKT.Top == 0))
{
Console.WriteLine("FOUND AND KILLING 0x" + hWndHost.ToString("X"));
PostMessage(hWndHost, 0x10 /* WM_CLOSE*/, (IntPtr)0x0, (IntPtr)0x0);
}
}
return false;
}
static void Main()
{
Console.WriteLine("Searching for hwnds...");
FindEdgeUIANDKILLIT();
Console.WriteLine("Done! Press any key to exit.");
Console.ReadKey();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment