using System; using System.Drawing; using System.Runtime.InteropServices; using System.Windows.Forms; // 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")] private static extern short GetKeyState(int nVirtKey); public static void Run(IntPtr windowHandle) { //run a function to minimize all the other windows BFS.DisplayFusion.RunFunction("Pause Desktop Wallpaper Slideshow"); //wait for other keys to be pressed while(!IsAnyKeyDown()) BFS.General.ThreadWait(10); //span the current window over all monitors BFS.DisplayFusion.RunFunction("Pause Desktop Wallpaper Slideshow"); } //this function uses the GetKeyState function to see if any keys are pressed private static bool IsAnyKeyDown() { //enumerate through all keys in the Keys enum foreach(Keys key in Enum.GetValues(typeof(Keys))) { //get the key's state short state = GetKeyState((int)key); //if the key isn't pressed, continue if((state & 0x8000) == 0) continue; //if the key is pressed, return true return true; } //we didn't find any keys that were pressed. return false return false; } }