using System; using System.Drawing; 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", CharSet = CharSet.Unicode, PreserveSig = true)] private static extern IntPtr FindWindow([MarshalAs(UnmanagedType.LPWStr)] string lpClassName, [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName); public static void Run(IntPtr windowHandle) { //get the system tray window IntPtr trayWnd = FindWindow("Shell_TrayWnd", null); //focus the window BFS.Window.Focus(trayWnd); //mute the computer BFS.Input.SendKeys("{VK_173}"); //send the nvidia surround hotkey BFS.Input.SendKeys("%(^(S))"); //wait for surround to be applied BFS.General.ThreadWait(3500); //unmute the computer BFS.Input.SendKeys("{VK_173}"); //load a monitor profile //NOTE: Change the profile names with profiles for your computer if(IsSurroundEnabled()) BFS.DisplayFusion.LoadMonitorProfileHideErrors("NVidia Surround Profile"); else BFS.DisplayFusion.LoadMonitorProfileHideErrors("Normal Profile"); } private static bool IsSurroundEnabled() { return (BFS.Monitor.GetPrimaryMonitorBounds().Width / (double)BFS.Monitor.GetPrimaryMonitorBounds().Height > 1.8d); } }