using System; using System.Drawing; using System.Windows.Forms; using System.Runtime.InteropServices; // The 'windowHandle' parameter will contain the window handle for the: // - Active window when run by hotkey // - Trigger target when run by a Trigger rule // - TitleBar Button owner when run by a TitleBar Button // - Jump List owner when run from a Taskbar Jump List // - Currently focused window if none of these match public static class DisplayFusionFunction { [DllImport("user32.dll")] public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, int wParam, int lParam); public static void Run(IntPtr windowHandle) { var appId = BFS.Application.GetAppIDByWindow(windowHandle); var sysTrayContainerHandle = BFS.Window.GetWindowByClass("Shell_TrayWnd"); var sysTrayHandle = BFS.Window.GetChildWindowByClass(sysTrayContainerHandle, "TrayNotifyWnd"); var sysPagerHandle = BFS.Window.GetChildWindowByClass(sysTrayHandle, "SysPager"); var notificationAreaHandle = BFS.Window.GetChildWindowByClass(sysPagerHandle, "ToolbarWindow32"); BFS.Application.Kill(appId); if (notificationAreaHandle == IntPtr.Zero) { var notifyIconOverflowWindowHandle = BFS.Window.GetWindowByClass("NotifyIconOverflowWindow"); var overflowNotificationAreaHandle = BFS.Window.GetChildWindowByClass(notifyIconOverflowWindowHandle, "ToolbarWindow32"); RefreshTrayArea(overflowNotificationAreaHandle); } RefreshTrayArea(notificationAreaHandle); } private static void RefreshTrayArea(IntPtr windowHandle) { const uint wmMousemove = 0x0200; var rect = BFS.Window.GetClientRect(windowHandle); for (var x = 0; x < rect.Right; x += 5) for (var y = 0; y < rect.Bottom; y += 5) SendMessage(windowHandle, wmMousemove, 0, (y << 16) + x); } }