{ "name": "Remove Borders, Size to Full Screen and Hide Taskbars", "language": 0, "code": "using System;\r\nusing System.Drawing;\r\n\r\n// The 'windowHandle' parameter will contain the window handle for the:\r\n// - Active window when run by hotkey\r\n// - Window Location target when run by a Window Location rule\r\n// - TitleBar Button owner when run by a TitleBar Button\r\n// - Jump List owner when run from a Taskbar Jump List\r\n// - Currently focused window if none of these match\r\npublic static class DisplayFusionFunction\r\n{\r\n\tpublic static void Run(IntPtr windowHandle)\r\n\t{\t\t\r\n\t\t// Get the window styles\r\n\t\tBFS.WindowEnum.WindowStyle style = BFS.Window.GetWindowStyle(windowHandle);\r\n\t\t\r\n\t\t// Get the monitor id\r\n\t\tuint monitorId = BFS.Monitor.GetMonitorIDByWindow(windowHandle);\r\n\t\t\r\n\t\t// If the window has any borders and titles, make it full screen\r\n\t\tif(BFS.Window.HasWindowStyle(BFS.WindowEnum.WindowStyle.WS_CAPTION, windowHandle) ||\r\n\t\t\tBFS.Window.HasWindowStyle(BFS.WindowEnum.WindowStyle.WS_SYSMENU, windowHandle) ||\r\n\t\t\tBFS.Window.HasWindowStyle(BFS.WindowEnum.WindowStyle.WS_THICKFRAME__SIZEBOX, windowHandle) ||\r\n\t\t\tBFS.Window.HasWindowStyle(BFS.WindowEnum.WindowStyle.WS_MINIMIZEBOX, windowHandle))\r\n\t\t{\r\n\t\t\t// Disable the taskbar\r\n\t\t\tBFS.Taskbar.SetWindowsTaskbarAutoHide(true);\r\n\t\t\tBFS.DisplayFusion.DisableTaskbar(monitorId);\r\n\r\n\t\t\t// Save the size and position of the window\r\n\t\t\tSaveWindowSize(windowHandle);\r\n\t\t\t\r\n\t\t\t// Make sure to remove the styles. just toggling these settings may turn on something we dont want\r\n\t\t\tstyle &= ~BFS.WindowEnum.WindowStyle.WS_CAPTION;\r\n\t\t\tstyle &= ~BFS.WindowEnum.WindowStyle.WS_SYSMENU;\r\n\t\t\tstyle &= ~BFS.WindowEnum.WindowStyle.WS_THICKFRAME__SIZEBOX;\r\n\t\t\tstyle &= ~BFS.WindowEnum.WindowStyle.WS_MINIMIZEBOX;\r\n\t\t\r\n\t\t\t// Get the bounds of the monitor that the window is in\r\n\t\t\tRectangle bounds = BFS.Monitor.GetMonitorBoundsByWindow(windowHandle);\r\n\t\t\t\r\n\t\t\t// Set the window style\r\n\t\t\tBFS.Window.SetWindowStyle(style, windowHandle);\r\n\t\t\t\t\t\t\r\n\t\t\t// Size and position the window to be fullscreen within the monitor\r\n\t\t\tBFS.Window.SetSizeAndLocation(windowHandle, bounds.X, bounds.Y, bounds.Width, bounds.Height);\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t// Enable the taskbar\r\n\t\t\tBFS.Taskbar.SetWindowsTaskbarAutoHide(false);\r\n\t\t\tBFS.DisplayFusion.EnableTaskbar(monitorId);\r\n\t\t\t\r\n\t\t\t// If we got here, then the window must already be fullscreen.\r\n\t\t\t// Add non-fullscreen styles back to the window\r\n\t\t\tstyle |= BFS.WindowEnum.WindowStyle.WS_CAPTION;\r\n\t\t\tstyle |= BFS.WindowEnum.WindowStyle.WS_SYSMENU;\r\n\t\t\tstyle |= BFS.WindowEnum.WindowStyle.WS_THICKFRAME__SIZEBOX;\r\n\t\t\tstyle |= BFS.WindowEnum.WindowStyle.WS_MINIMIZEBOX;\r\n\t\t\tstyle |= BFS.WindowEnum.WindowStyle.WS_MAXIMIZEBOX;\r\n\t\t\t\r\n\t\t\t// Try and load saved window size and position\r\n\t\t\tbool isMaximized;\r\n\t\t\tRectangle bounds = GetSavedWindowSize(windowHandle, out isMaximized);\r\n\t\t\t\r\n\t\t\t// Set the window style\r\n\t\t\tBFS.Window.SetWindowStyle(style, windowHandle);\r\n\t\t\t\r\n\t\t\t// If we couldnt load the size, exit the script\r\n\t\t\tif(bounds.Equals(Rectangle.Empty))\r\n\t\t\t\treturn;\r\n\t\t\t\t\r\n\t\t\t// If the window was maximized, maximize it, otherwise set the window size and location with the values we loaded\r\n\t\t\tif(isMaximized)\r\n\t\t\t\tBFS.Window.Maximize(windowHandle);\r\n\t\t\telse\r\n\t\t\t\tBFS.Window.SetSizeAndLocation(windowHandle, bounds.X, bounds.Y, bounds.Width, bounds.Height);\r\n\t\t}\r\n\t}\r\n\t\r\n\t// This is a function that will save the window size and position in window properties\r\n\tprivate static void SaveWindowSize(IntPtr windowHandle)\r\n\t{\r\n\t\tRectangle bounds = BFS.Window.GetBounds(windowHandle);\r\n\t\tBFS.Window.SetWindowProperty(windowHandle, \"ToggleFullscreen_X\", new IntPtr(bounds.X));\r\n\t\tBFS.Window.SetWindowProperty(windowHandle, \"ToggleFullscreen_Y\", new IntPtr(bounds.Y));\r\n\t\tBFS.Window.SetWindowProperty(windowHandle, \"ToggleFullscreen_Width\", new IntPtr(bounds.Width));\r\n\t\tBFS.Window.SetWindowProperty(windowHandle, \"ToggleFullscreen_Height\", new IntPtr(bounds.Height));\r\n\t\tBFS.Window.SetWindowProperty(windowHandle, \"ToggleFullscreen_IsMaximized\", new IntPtr(BFS.Window.IsMaximized(windowHandle) ? 1 : 0));\r\n\t}\r\n\t\r\n\tprivate static Rectangle GetSavedWindowSize(IntPtr windowHandle, out bool isMaximized)\r\n\t{\r\n\t\tRectangle bounds = new Rectangle();\r\n\t\tbounds.X = BFS.Window.GetWindowProperty(windowHandle, \"ToggleFullscreen_X\").ToInt32();\r\n\t\tbounds.Y = BFS.Window.GetWindowProperty(windowHandle, \"ToggleFullscreen_Y\").ToInt32();\r\n\t\tbounds.Width = BFS.Window.GetWindowProperty(windowHandle, \"ToggleFullscreen_Width\").ToInt32();\r\n\t\tbounds.Height = BFS.Window.GetWindowProperty(windowHandle, \"ToggleFullscreen_Height\").ToInt32();\r\n\t\tisMaximized = (BFS.Window.GetWindowProperty(windowHandle, \"ToggleFullscreen_IsMaximized\").ToInt32() == 1);\r\n\t\treturn bounds;\r\n\t}\r\n}", "description": "", "references": "Microsoft.VisualBasic.Core.dll|Microsoft.Win32.Primitives.dll|Microsoft.Win32.Registry.dll|netstandard.dll|Newtonsoft.Json.dll|System.Collections.Concurrent.dll|System.Collections.dll|System.Collections.Immutable.dll|System.Collections.NonGeneric.dll|System.Collections.Specialized.dll|System.ComponentModel.Primitives.dll|System.ComponentModel.TypeConverter.dll|System.Console.dll|System.Core.dll|System.Data.dll|System.Diagnostics.Process.dll|System.dll|System.Drawing.Common.dll|System.Drawing.dll|System.Drawing.Primitives.dll|System.IO.Compression.dll|System.IO.dll|System.IO.FileSystem.Watcher.dll|System.Linq.dll|System.Linq.Expressions.dll|System.Linq.Parallel.dll|System.Linq.Queryable.dll|System.Management.dll|System.Net.dll|System.Net.Primitives.dll|System.Net.Requests.dll|System.Net.WebClient.dll|System.Net.WebHeaderCollection.dll|System.Private.CoreLib.dll|System.Private.Uri.dll|System.Private.Xml.dll|System.Runtime.dll|System.Runtime.InteropServices.dll|System.Runtime.Serialization.Formatters.dll|System.Security.Cryptography.Algorithms.dll|System.Security.Cryptography.Csp.dll|System.Security.Cryptography.dll|System.Security.Cryptography.Primitives.dll|System.Text.Json.dll|System.Text.RegularExpressions.dll|System.Threading.dll|System.Threading.Tasks.dll|System.Threading.Tasks.Parallel.dll|System.Web.dll|System.Web.HttpUtility.dll|System.Windows.Extensions.dll|System.Windows.Forms.dll|System.Windows.Forms.Primitives.dll|System.Xml.dll" }