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?
Save up to 50% on our desktop apps during our Year End Sale!Save up to 50% on our desktop apps during our Year End Sale, including DisplayFusion, ClipboardFusion, FileSeek, LogFusion, TrayStatus, and VoiceBot!Save up to 50% on our desktop apps during our Year End Sale!

Toggle TitleBar Buttons Based on Number of Monitors

Description
This script will check if there are 1 or 2 monitors connected. If there's only 1, it will disable the TitleBar Buttons. If there are 2, it will enable them.
Language
C#.net
Minimum Version
Created By
Keith Lammers (BFS)
Contributors
-
Date Created
Oct 16, 2019
Date Last Modified
Oct 16, 2019

Scripted Function (Macro) Code

using System;
using System.Drawing;
using Microsoft.Win32;

public static class DisplayFusionFunction
{
	public static void Run(IntPtr windowHandle)
	{
        // Gets the number of monitors attached to the system
        int numberOfMonitors = BFS.Monitor.GetMonitorCountEnabledNoSplits();
        
        // If there are 2, enable the titlebar buttons    
        if (numberOfMonitors == 2)
        {
            if (!TitleBarButtonsEnabled())
                BFS.DisplayFusion.RunFunction("Toggle TitleBar Buttons");
        }
        
        // If there's only 1, disable the titlebar buttons
        else if (numberOfMonitors == 1)
        {
            if (TitleBarButtonsEnabled())
                BFS.DisplayFusion.RunFunction("Toggle TitleBar Buttons");
        }
	}
	
	private static bool TitleBarButtonsEnabled()
	{
        // Check the registry to see if titlebar buttons are enabled, and return a true or false
        using (RegistryKey key = Registry.CurrentUser.OpenSubKey("Software\\Binary Fortress Software\\DisplayFusion"))
        {
            if (key != null)
            {
                Object TitleBarButtonsEnabledValue = key.GetValue("TitleBarButtonsEnabled");
                
                if (TitleBarButtonsEnabledValue.ToString() == "1")
                    return true;
                else
                    return false;
            }
            else
            {
                return false;
            }
        }
	}
}