using System; using System.Drawing; using System.Linq; public static class DisplayFusionFunction { /** Requirements: (1) A Steam installation. https://store.steampowered.com/about/ (2) A monitor profile that you intend to use for Steam's Big Picture mode. https://www.displayfusion.com/HelpGuide/DisplayFusionBeginnersGuide/#MonitorProfiles (3) (optional) A profile you intend to revert to when Steam exits big picture mode. (4) (optional) A desktop icon profile to revert to after profile reversion. This is especially helpful when icons are shuffled after monitor profile changes. https://www.displayfusion.com/HelpGuide/DisplayFusionBeginnersGuide/#DesktopIconProfiles Instructions: (1) Change the value of "gamingMonitorProfile" to the name of the monitor profile you intend to use Steam on. Your monitor profile will be exactly as you named it. Steam Big Picture mode will launch on the primary monitor in the profile. (2) Change "steamExec" value to your Steam.exe path. Currently it is set to the most common path. (3) (optional) Change the value of "defaultMonitorProfile" to the monitor profile you intend to revert to once Steam Big Picture mode is exited. If you intend to use this feature, you should also set the value of "switchBackOnExit" to "true". (4) (optional) Change the value of "iconProfile" to the Desktop Icons profile you intend to revert to when your monitor profile switches back. If you intend to use this feature, you should also set the value of "resetIconPositions" to "true". This feature is only effective if the "switchBackOnExit" feature is also "true". */ // Profile settings static string gamingMonitorProfile = "Console TV"; static string defaultMonitorProfile = "Default PC v2"; static string iconProfile = "[Your desktop icons profile]"; // Steam executable location (don't forget the double backslashes) static string steamExec = "C:\\Program Files (x86)\\Steam\\steam.exe"; // Options static bool switchBackOnExit = true; // Switch to the default monitor profile upon BPM exit. static bool resetIconPositions = false; // Set Desktop Icon profile when Monitor profile is reverted. static bool moveTheMouse = true; // Move the mouse to the top left corner to avoid interference with Steam. static bool slowPC = false; // If it takes more than 5 seconds for Steam to load, set this to true. // Begin code public static void Run(IntPtr windowHandle) { // Check that the profiles are valid before proceeding. if(checkProfiles()) { // Switch to "Gaming" profile BFS.DisplayFusion.LoadMonitorProfile(gamingMonitorProfile); // Move the mouse out of the way mouseTrap(); // Check steam windows IntPtr window = BFS.Window.GetWindowByText("*Steam Big Picture Mode*"); IntPtr steam = BFS.Window.GetWindowByText("*Steam*"); // If BPM is running if(window != IntPtr.Zero) { // Move it to the main window BFS.Window.MoveToMonitor(1, window); // Focus on the window BFS.Window.Focus(window); } // BPM is not running else { // Steam is running if(steam != IntPtr.Zero) { // Request BPM BFS.Application.Start("steam://open/bigpicture"); } // Steam is not running else { // Launch Steam in BPM BFS.Application.Start(steamExec, "steam://open/bigpicture"); } } checkForExit(); } } // Check to see if the profiles are valid private static bool checkProfiles() { string[] monitorProfiles = BFS.DisplayFusion.GetMonitorProfiles(); string[] iconProfiles = BFS.DisplayFusion.GetDesktopIconsProfiles(); if(!monitorProfiles.Contains(gamingMonitorProfile)) { BFS.Dialog.ShowMessageError($"'{gamingMonitorProfile}' is not a valid monitor profile. Please check that you have a monitor profile with this name."); return false; } else if(switchBackOnExit && !monitorProfiles.Contains(defaultMonitorProfile)) { BFS.Dialog.ShowMessageError($"'{defaultMonitorProfile}' is not a valid monitor profile. Please check that you have a monitor profile with this name."); return false; } else if(resetIconPositions && !iconProfiles.Contains(iconProfile)) { BFS.Dialog.ShowMessageError($"'{iconProfile}' is not a valid desktop icon profile. Please check that you have a monitor profile with this name."); return false; } return true; } // Move the mouse to the top left (0,0) private static void mouseTrap() { if(moveTheMouse) { while(true) { if(BFS.DisplayFusion.GetCurrentMonitorProfile() == gamingMonitorProfile) { BFS.Input.SetMousePosition(0,0); break; } } } } // Check if BPM has exited, and switch to the default monitor profile if it has. private static void checkForExit() { if(switchBackOnExit) { // Wait 5 seconds before attempting to check (15 seconds if "slowPC" option is selected). uint waitTime = (uint) (slowPC ? 15000 : 5000); BFS.General.ThreadWait(waitTime); while(true) { IntPtr window = BFS.Window.GetWindowByText("*Steam Big Picture Mode*"); if(window == IntPtr.Zero) { BFS.DisplayFusion.LoadMonitorProfile(defaultMonitorProfile); BFS.DisplayFusion.LoadDesktopIconsProfile(iconProfile); break; } } } } }