// NativeMethods Class using System; using System.Runtime.InteropServices; namespace RefreshNotificationArea { internal class NativeMethods { [StructLayout(LayoutKind.Sequential)] internal struct RECT { public int left; public int top; public int right; public int bottom; } [DllImport("user32.dll", CharSet = CharSet.Unicode)] internal static extern IntPtr FindWindow(string lpClassName, string lpWindowName); [DllImport("user32.dll", CharSet = CharSet.Unicode)] internal static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow); [DllImport("user32.dll", CharSet = CharSet.Unicode)] [return: MarshalAs(UnmanagedType.Bool)] internal static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect); [DllImport("user32.dll", CharSet = CharSet.Auto)] internal static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, int wParam, int lParam); } } // Main using System; namespace RefreshNotificationArea { class Program { static void Main(string[] args) { RefreshTrayArea(); } public static void RefreshTrayArea() { IntPtr systemTrayContainerHandle = NativeMethods.FindWindow("Shell_TrayWnd", null); IntPtr systemTrayHandle = NativeMethods.FindWindowEx(systemTrayContainerHandle, IntPtr.Zero, "TrayNotifyWnd", null); IntPtr sysPagerHandle = NativeMethods.FindWindowEx(systemTrayHandle, IntPtr.Zero, "SysPager", null); IntPtr notificationAreaHandle = NativeMethods.FindWindowEx(sysPagerHandle, IntPtr.Zero, "ToolbarWindow32", "Notification Area"); if (notificationAreaHandle == IntPtr.Zero) { notificationAreaHandle = NativeMethods.FindWindowEx(sysPagerHandle, IntPtr.Zero, "ToolbarWindow32", "User Promoted Notification Area"); IntPtr notifyIconOverflowWindowHandle = NativeMethods.FindWindow("NotifyIconOverflowWindow", null); IntPtr overflowNotificationAreaHandle = NativeMethods.FindWindowEx(notifyIconOverflowWindowHandle, IntPtr.Zero, "ToolbarWindow32", "Overflow Notification Area"); RefreshTrayArea(overflowNotificationAreaHandle); } RefreshTrayArea(notificationAreaHandle); } private static void RefreshTrayArea(IntPtr windowHandle) { const uint wmMousemove = 0x0200; NativeMethods.GetClientRect(windowHandle, out NativeMethods.RECT rect); for (var x = 0; x < rect.right; x += 5) { for (var y = 0; y < rect.bottom; y += 5) { NativeMethods.SendMessage(windowHandle, wmMousemove, 0, (y << 16) + x); } } } } }