Processing Ajax...

Title

Message

Confirm

Confirm

Confirm

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure you want to delete this item?

Confirm

Are you sure?

User Image
john mccall1
2 discussion posts
Hello, I'm trying to use this function https://www.displayfusion.com/ScriptedFunctions/View/?ID=018cf550-e36a-77ea-88f6-aed3ae6317bc To switch to a different monitor profile and open Steam in Big Picture mode. But while the Monitor Profile switching part works, I can't seem to get any function to interact with steam at all, even though I'm confident the file path is correct.

Here's how I have it set right now:

Code

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;
                }
            }
        }
    }
}


My Steam path is "C:\Program Files (x86)\Steam\steam.exe", so I have no idea why this wont open Big Picture, or even just regular Steam.
Jun 30, 2024 (modified Jun 30, 2024)  • #1
User Image
john mccall1
2 discussion posts
I figured out what the problem was, turns out in had nothing to do with the code. The Monitor Profile I was switching to was broken in some way and had an asterix next to the name, so even though it was working perfectly fine as is it stopped functions from working correctly I geuss. I just re-saved it as a new Profile and that seems to have fixed it.
Jul 1, 2024 (modified Jul 1, 2024)  • #2
Jon Tackabury (BFS)'s profile on WallpaperFusion.com
Hi John, that's great to hear I'm happy to hear you got it sorted out. :)
Jul 1, 2024  • #3
Subscribe to this discussion topic using RSS
Was this helpful?  Login to Vote(-)  Login to Vote(-)