Skip to content

Instantly share code, notes, and snippets.

@PatoFlamejanteTV
Created August 5, 2025 19:54
Show Gist options
  • Select an option

  • Save PatoFlamejanteTV/21640468e02cc96688532e851f310a01 to your computer and use it in GitHub Desktop.

Select an option

Save PatoFlamejanteTV/21640468e02cc96688532e851f310a01 to your computer and use it in GitHub Desktop.
Simple tool for using the FlashWindow() function.
[StructLayout(LayoutKind.Sequential)]
public struct FLASHWINFO
{
public uint cbSize;
public IntPtr hwnd;
public uint dwFlags;
public uint uCount;
public uint dwTimeout;
}
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool FlashWindowEx(ref FLASHWINFO pwfi);
// Flash window flags
public const uint FLASHW_STOP = 0;
public const uint FLASHW_CAPTION = 1;
public const uint FLASHW_TRAY = 2;
public const uint FLASHW_ALL = 3;
public const uint FLASHW_TIMER = 4;
public const uint FLASHW_TIMERNOFG = 12;
public static bool FlashWindowEx(IntPtr hWnd, uint flags, uint count, uint timeout)
{
FLASHWINFO fInfo = new FLASHWINFO();
fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo));
fInfo.hwnd = hWnd;
fInfo.dwFlags = flags;
fInfo.uCount = count;
fInfo.dwTimeout = timeout;
return FlashWindowEx(ref fInfo);
}
// Usage:
// Flash both caption and taskbar button 5 times
FlashWindowEx(this.Handle, FLASHW_ALL, 5, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment