using System;
using System.Drawing;
using System.Runtime.InteropServices;
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)
{
//set these to the names of your extended and surround Monitor Profiles
string surroundProfile = "NVidia Surround Profile";
string extendedProfile = "Extended Profile";
//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(10000);
//unmute the computer
BFS.Input.SendKeys("{VK_173}");
//load a monitor profile
if(IsSurroundEnabled())
BFS.DisplayFusion.LoadMonitorProfileHideErrors(surroundProfile);
else
BFS.DisplayFusion.LoadMonitorProfileHideErrors(extendedProfile);
}
private static bool IsSurroundEnabled()
{
return (BFS.Monitor.GetPrimaryMonitorBounds().Width / (double)BFS.Monitor.GetPrimaryMonitorBounds().Height > 1.8d);
}
}