{ "name": "Switch to Monitor Profile and Back (with Window Position Save/Restore)", "language": 0, "code": "using System;\r\nusing System.Drawing;\r\n\r\npublic static class DisplayFusionFunction\r\n{\r\n\tpublic static void Run(IntPtr windowHandle)\r\n\t{\r\n\t\t// Set your monitor profile names here\r\n\t\tstring sourceMonitorProfile = \"Monitor Profile 1\";\r\n\t\tstring targetMonitorProfile = \"Monitor Profile 2\";\r\n\t\t\r\n\t\t// Load the profile and save or restore the positions\r\n\t\tif (BFS.DisplayFusion.GetCurrentMonitorProfile() == sourceMonitorProfile)\r\n\t\t{\r\n BFS.DisplayFusion.RunFunctionAndWait(\"Save Window Positions\");\r\n BFS.DisplayFusion.LoadMonitorProfile(targetMonitorProfile);\r\n\t\t}\r\n\t\telse if (BFS.DisplayFusion.GetCurrentMonitorProfile() == targetMonitorProfile)\r\n\t\t{\r\n BFS.DisplayFusion.LoadMonitorProfile(sourceMonitorProfile);\r\n BFS.General.ThreadWait(5000);\r\n BFS.DisplayFusion.RunFunctionAndWait(\"Restore Window Positions From Last Save\");\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n BFS.Dialog.ShowMessageError(\"Neither the source or target Monitor Profile were detected as the current profile. Exiting the script.\");\r\n\t\t}\r\n\t}\r\n}", "description": "", "references": "System.Core.dll | System.Data.dll | System.dll | System.Drawing.dll | System.Management.dll | System.Web.dll | System.Windows.Forms.dll | System.Xml.dll" }