Login / Register
▼
Binary Fortress
Binary Fortress Software
CheckCentral
ClipboardFusion
CloudShow
DisplayFusion
FileSeek
HashTools
LogFusion
Notepad Replacer
Online Base64 Decoder
Online Base64 Encoder
Online JSON Formatter
ShellSend
TrayStatus
VoiceBot
WallpaperFusion
Window Inspector
More Apps...
DisplayFusion
CheckCentral
CloudShow
ClipboardFusion
FileSeek
VoiceBot
WallpaperFusion
Home
▼
Download
Download
Change Log
Download Beta
Beta Change Log
License (EULA)
▼
Features
Features
Incredible Desktop Wallpaper
Monitor Configuration
Monitor Splitting
Powerful Functions
Triggers
Multi-Monitor Taskbars
Useful Windows 10 Tweaks
Useful Windows 8 Tweaks
Windows Lock Screen
Multi-Monitor Screen Savers
Monitor Fading
Window Snapping
Window Management
Mouse Management
Alt+Tab Handler
Window Position Profiles
Desktop Icon Profiles
Remote Control
Available in dozens of Languages
Easy Administration
Free vs Pro
Purchase
Screenshots
Languages
▼
Help
Help Guide
FAQ
Discussions
Contact Us
Find My License
Mailing Address
Advanced Settings
Scripted Functions (Macros)
Display
Fusion
by Binary Fortress Software
WARNING: You currently have Javascript disabled!
This website will not function correctly without Javascript enabled.
Title
Message
OK
Confirm
Yes
No
Toggle Duplicate and Extend Monitors Using DisplaySwitch.exe
Return to DisplayFusion Scripted Functions (Macros)
Description
This script will use Windows' displayswitch.exe to toggle between cloned and extended monitors.
Language
C# (.Net)
Minimum Version
9.6.1+
Created By
Dylan24578
Contributors
-
Date Created
Jan 8, 2020
Date Last Modified
Jan 8, 2020
Scripted Function (Macro) Code
Copy
Select All
using System; using System.Drawing; using System.IO; public static class DisplayFusionFunction { public static void Run() { //Read/Write file Variables, used to determine current monitor states string appdata = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); //Appdata Roaming folder string folder = @"\displayfusionscripts\"; //scripts folder string folderPath = appdata + folder; string path = appdata + folder + "data.txt"; //full file path //First time setup, create directory and data.txt in appdata if(!File.Exists(path)){ createFile(folderPath, path); } //Read file StreamReader sr = new StreamReader(path); string data = sr.ReadLine(); sr.Close(); string c = "/clone"; string e = "/extend"; //Check data, change data.txt for next use if(data == c) { writeToFile(path, e); } else if (data == e) { writeToFile(path, c); } else { writeToFile(path, c); } //run built-in Windows DisplaySwitch.exe with the /extend BFS.Application.Start("DisplaySwitch.exe", data); } //Creates directory and file if they don't exist static void createFile(string folderPath, string path){ Directory.CreateDirectory(folderPath); File.Create(path); } //Writes data to file static void writeToFile(string path, string data) { try{ StreamWriter sw = new StreamWriter(path); sw.WriteLine(data); sw.Close(); } catch(Exception e){ Console.WriteLine(e.Message); } } }
Copyright © 2007-2021 Binary Fortress Software
•
News
•
Discussions
•
FAQ
•
Support
•
Privacy
•
ToS
•
Get DisplayFusion Merch