using System;
using System.Drawing;
using System.Collections.Generic;
// 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.LoadMonitorProfile("Default");
System.Threading.Thread.Sleep(3000); //Wait
BFS.DisplayFusion.LoadWallpaperProfile("Default");
}
// nVidia Surround / AMD Eyefinity
else if (BFS.ScriptSettings.ReadValue("Surround") == "true")
{
BFS.DisplayFusion.LoadMonitorProfile("Nvidia Surround");
System.Threading.Thread.Sleep(3000); //Wait
BFS.DisplayFusion.LoadWallpaperProfile("Nvidia Surround");
}
}
//Manipulates Nvidia control panel to Enable Surround.
public static void EnableSurround()
{
BFS.DisplayFusion.SaveDesktopIconsProfile("Default");
BFS.ScriptSettings.WriteValue("Surround", "true");
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.DisplayFusion.SaveDesktopIconsProfile("Surround");
BFS.ScriptSettings.WriteValue("Surround", "false");
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
}
}