{ "name": "Move Window to Next Monitor Maximized Then Back to Its Original Location", "language": 0, "code": "using System;\r\nusing System.Drawing;\r\nusing System.Runtime.InteropServices;\r\n\r\n// The 'windowHandle' parameter will contain the window handle for the:\r\n// - Active window when run by hotkey\r\n// - Trigger target when run by a Trigger 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\tprivate const string WindowProperty = \"OriginalPositionAndSize\";\r\n\t\r\n\tpublic static void Run(IntPtr windowHandle)\r\n\t{\r\n\t\t// Try and get the saved window property\r\n\t\tIntPtr prop = BFS.Window.GetWindowProperty(windowHandle, WindowProperty);\r\n\t\t\r\n\t\t// If the property doesn't exist, save the position and size then move the window\r\n\t\tif(prop == IntPtr.Zero)\r\n\t\t{\r\n\t\t\t// Get the window bounds\r\n\t\t\tRectangle bounds = BFS.Window.GetBounds(windowHandle);\r\n\t\t\t\r\n\t\t\t// Allocate memory to store the window bounds\r\n\t\t\tIntPtr pointer = Marshal.AllocHGlobal(Marshal.SizeOf());\r\n\t\t\t\r\n\t\t\t// Write the window bounds to the allocated memory\r\n\t\t\tMarshal.StructureToPtr(bounds, pointer, false);\r\n\t\t\t\r\n\t\t\t// Attach the original window bounds to the window as a property\r\n\t\t\tBFS.Window.SetWindowProperty(windowHandle, WindowProperty, pointer);\r\n\t\t\t\r\n\t\t\t// Move the window to the next monitor and maximize it\r\n\t\t\tBFS.Window.MoveToNextMonitorMaximized(windowHandle);\r\n\t\t\t\r\n\t\t\t// Exit the script\r\n\t\t\treturn;\r\n\t\t}\r\n\t\t\r\n\t\t// Get the original position and size from the property\r\n\t\tRectangle originalBounds = Marshal.PtrToStructure(prop);\r\n\t\t\r\n\t\t// Remove the window property\r\n\t\tBFS.Window.RemoveWindowProperty(windowHandle, WindowProperty);\r\n\t\t\r\n\t\t// Move the window back\r\n\t\tBFS.Window.SetSizeAndLocation(windowHandle, originalBounds.X, originalBounds.Y, originalBounds.Width, originalBounds.Height);\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" }