An error has occurred while applying your new Monitor configuration. Please check your settings and try again. Error: CurrentMonitor is NULL [1]: Current: [NVIDIA GeForce GTX 970\Generic PnP Monitor (ID: 2 • Primary: False • Attached: False • Extra: False • Split: False • Split Padding: L=0, R=0, T=0, B=0 • Bounds: {X=0,Y=0,Width=0,Height=0} • WorkArea: {X=0,Y=0,Width=0,Height=0} • Clone: {X=0,Y=0,Width=0,Height=0} • Driver: Unknown • Device: \\.\DISPLAY30 • TA:ID: 0 • TA:AID: 0:0 • Output: Other • DPIScaleX: 0 • DPIScaleY: 0 • Orientation: Landscape)] All: Count: 4 - NVIDIA GeForce GTX 970\IPS236 (ID: 1 • Primary: False • Attached: False • Extra: False • Split: False • Split Padding: L=0, R=0, T=0, B=0 • Bounds: {X=0,Y=0,Width=0,Height=0} • WorkArea: {X=0,Y=0,Width=0,Height=0} • Clone: {X=0,Y=0,Width=0,Height=0} • Driver: Unknown • Device: • TA:ID: 1048850 • TA:AID: 359663079:0 • Output: DisplayPortExternal • DPIScaleX: 0 • DPIScaleY: 0 • Orientation: Landscape) - NVIDIA GeForce GTX 970\IPS236 (ID: 2 • Primary: True • Attached: True • Extra: False • Split: False • Split Padding: L=0, R=0, T=0, B=0 • Bounds: {X=0,Y=0,Width=1920,Height=1080} • WorkArea: {X=0,Y=0,Width=1920,Height=1040} • Clone: {X=0,Y=0,Width=0,Height=0} • Driver: Builtin • Device: \\.\DISPLAY29 • TA:ID: 1048852 • TA:AID: 359663079:0 • Output: DisplayPortExternal • DPIScaleX: 0 • DPIScaleY: 0 • Orientation: Landscape) - NVIDIA GeForce GTX 970\IPS236 (ID: 3 • Primary: False • Attached: False • Extra: False • Split: False • Split Padding: L=0, R=0, T=0, B=0 • Bounds: {X=0,Y=0,Width=0,Height=0} • WorkArea: {X=0,Y=0,Width=0,Height=0} • Clone: {X=0,Y=0,Width=0,Height=0} • Driver: Unknown • Device: • TA:ID: 1048849 • TA:AID: 359663079:0 • Output: HDMI • DPIScaleX: 0 • DPIScaleY: 0 • Orientation: Landscape) - NVIDIA GeForce GTX 970\DELL 2005FPW (ID: 4 • Primary: False • Attached: False • Extra: False • Split: False • Split Padding: L=0, R=0, T=0, B=0 • Bounds: {X=0,Y=0,Width=0,Height=0} • WorkArea: {X=0,Y=0,Width=0,Height=0} • Clone: {X=0,Y=0,Width=0,Height=0} • Driver: Unknown • Device: • TA:ID: 1048848 • TA:AID: 359663079:0 • Output: DVI • DPIScaleX: 0 • DPIScaleY: 0 • Orientation: Landscape)
using System; using System.Drawing; // The 'windowHandle' parameter will contain the window handle for the: // - Active window when run by hotkey // - Window Location target when run by a Window Location 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 { public static void Run(IntPtr windowHandle) { //Nvidia control panel executable location. string nvctl = "A:\\Program Files\\NVIDIA Corporation\\Control Panel Client\\nvcplui.exe"; //Can add to or remove from list to fit needs. string[] predictedPrograms = { "A:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe", "A:\\Program Files\\Logitech Gaming Software\\LCore.exe", "A:\\Program Files (x86)\\Skype\\Phone\\Skype.exe" }; //Saves all running Programs string[] arr = BFS.Application.GetAllRunningApplicationFiles(); //Close predicted Programs. for (int i = 0; i < predictedPrograms.Length; ++i) BFS.Application.Kill(BFS.Application.GetAppIDByFile(predictedPrograms[i])); BFS.Application.Start(nvctl, ""); System.Threading.Thread.Sleep(800); //Wait BFS.Window.SetLocation(BFS.Window.GetWindowByText("NVIDIA Control Panel"),0,0); if (BFS.ScriptSettings.ReadValue("Surround") == "true") DisableSurround(); else EnableSurround(); //Wait for nvctl to get closed by user. BFS.Application.WaitForExitByFile(nvctl,0); //Re-Open predicted Programs. for (int i = 0; i < arr.Length; ++i) if (!BFS.Application.IsAppRunningByFile(arr[i])) BFS.Application.Start(arr[i], ""); /* // default Resolution if (BFS.ScriptSettings.ReadValue("Surround") == "false") BFS.DisplayFusion.RunFunction("Load Monitor Profile: Default"); // nVidia Surround / AMD Eyefinity else if (BFS.ScriptSettings.ReadValue("Surround") == "true") BFS.DisplayFusion.RunFunction("Load Wallpaper Profile: Nvidia Surround");*/ BFS.DisplayFusion.RunFunction("Update Monitor Profile"); //included toggle if (BFS.ScriptSettings.ReadValue("Surround") == "false") BFS.ScriptSettings.WriteValue("Surround", "true"); else BFS.ScriptSettings.WriteValue("Surround", "false"); } //Manipulates Nvidia control panel to Enable Surround. public static void EnableSurround() { BFS.Input.SetMousePosition(337, 279); BFS.Input.LeftClickMouse(); System.Threading.Thread.Sleep(500); //Wait BFS.Input.SetMousePosition(831, 685); BFS.Input.LeftClickMouse(); System.Threading.Thread.Sleep(500); //Wait } //Manipulates Nvidia control panel to Disable Surround. public static void DisableSurround() { BFS.Input.SetMousePosition(337, 258); BFS.Input.LeftClickMouse(); System.Threading.Thread.Sleep(500); //Wait BFS.Input.SetMousePosition(831, 685); BFS.Input.LeftClickMouse(); System.Threading.Thread.Sleep(500); //Wait } }
using System; using System.Drawing; using System.Windows.Forms; //Code brought to you by: solaris765 //Because numbers after my screen name are fun. //Automatically changes Monitor Profile based on resolution changes. // // The 'windowHandle' parameter will contain the window handle for the: // - Active window when run by hotkey // - Window Location target when run by a Window Location 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 { public static void Run(IntPtr windowHandle) { int defaultResolutionWidth = 1920; int nonstandardReslolutionWidth = 5760; // default Resolution if (Screen.PrimaryScreen.Bounds.Width == defaultResolutionWidth) { BFS.DisplayFusion.LoadMonitorProfile("Default"); BFS.ScriptSettings.WriteValue("Profile", "Default"); } // nVidia Surround / AMD Eyefinity else if (Screen.PrimaryScreen.Bounds.Width == nonstandardReslolutionWidth) { BFS.DisplayFusion.LoadMonitorProfile("Nvidia Surround"); BFS.ScriptSettings.WriteValue("Profile", "Nvidia Surround"); } } }