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
WARNING: You currently have Javascript disabled!
This website will not function correctly without Javascript enabled.
Title
Message
OK
Confirm
Yes
No
Move Window to Virtual Desktop 2 (Win 10)
Return to DisplayFusion Scripted Functions (Macros)
Description
Note: The DLLs provided in this function were not compiled by Binary Fortress Software. Use at your own risk.
Windows 1803 use VirtualDesktop-Windows-v1803.dll, rename to VirtualDesktop.dll
Language
C# (.Net)
Minimum Version
9.2.2+
Created By
Ben Richards
Contributors
-
Date Created
Jun 6, 2018
Date Last Modified
Jun 6, 2018
Scripted Function (Macro) Code
Copy
Select All
Toggle Line Wrapping
using System; using System.Drawing; using System.Collections.Generic; using WindowsDesktop; // Windows < v1803 // Add to reference | Disk:\YourPathToDll\VirtualDesktop.dll from (https://github.com/Grabacr07/VirtualDesktop/tree/master) // Compiled binaries // https://www.dropbox.com/s/qgdpr0q3xxqvyvz/VirtualDesktop.dll?dl=0 // Windows < 1803 use VirtualDesktop.dll // Windows > 1803 use VirtualDesktop-Windows-v1803.dll, rename to VirtualDesktop.dll public static class DisplayFusionFunction { public static void Run(IntPtr windowHandle) { var vDesktop = new VirtualDesktops(); /// Get a dictionary of all desktops var desktops = vDesktop.GetAllDesktops(); /// Get desired desktop and move the applicatio to it var deskSecond = desktops["Desktop 2"]; vDesktop.SwitchToDesktop(deskSecond); vDesktop.MoveWindowToDesktop(windowHandle, deskSecond); BFS.Window.Focus(windowHandle); } } class VirtualDesktops { // Create new virtual desktop public void Create() { VirtualDesktop.Create(); } // Remove current virtual desktop public void Remove() { VirtualDesktop.Current.Remove(); } // Switch to the left virtual desktop relative to the current public void SwitchToLeft() { VirtualDesktop.Current.GetLeft().Switch(); } // Switch to the right virtual desktop relative to the current public void SwitchToRight() { VirtualDesktop.Current.GetRight().Switch(); } // Switch to desired virtual desktop by key public void SwitchToDesktop(VirtualDesktop vDesktop) { vDesktop.Switch(); } // Move the window to the left virtual desktop relative to the current public void MoveWindowToLeft(IntPtr wHandle) { var left = VirtualDesktop.Current.GetLeft(); VirtualDesktopHelper.MoveToDesktop(wHandle, left); } // Move the window to the right virtual desktop relative to the current public void MoveWindowToRight(IntPtr wHandle) { var right = VirtualDesktop.Current.GetRight(); VirtualDesktopHelper.MoveToDesktop(wHandle, right); } // Move the window from either virtual desktop to the current public void MoveWindowToCurrent(IntPtr wHandle) { var currentDesktop = VirtualDesktop.Current; if(!VirtualDesktopHelper.IsCurrentVirtualDesktop(wHandle)) VirtualDesktopHelper.MoveToDesktop(wHandle, currentDesktop); } // Move the window to specified virtual desktop public void MoveWindowToDesktop(IntPtr wHandle, VirtualDesktop virtualDesktop) { VirtualDesktopHelper.MoveToDesktop(wHandle, virtualDesktop); } // Pin window. Show this window on all desktops public void TogglePin(IntPtr wHandle) { (VirtualDesktop.IsPinnedWindow(wHandle) ? VirtualDesktop.UnpinWindow : (Action<IntPtr>)VirtualDesktop.PinWindow)(wHandle); } // Pin app. Show windows from this app on all desktops public void TogglePinApp(IntPtr wHandle) { var appId = ApplicationHelper.GetAppId(wHandle); (VirtualDesktop.IsPinnedApplication(appId) ? VirtualDesktop.UnpinApplication : (Action<string>)VirtualDesktop.PinApplication)(appId); } // Returns a virtual desktop that window is located public VirtualDesktop GetCurrentWindowDesktop(IntPtr wHandle) { return VirtualDesktop.FromHwnd(wHandle); } // Return all the virtual desktops of currently valid public Dictionary<string, VirtualDesktop> GetAllDesktops() { var desktopArray = VirtualDesktop.GetDesktops(); var desktopDictionary = new Dictionary<string, VirtualDesktop>(); // To simplify selection by key, used (j+1) for (var j = 0; j < desktopArray.Length; j++) desktopDictionary.Add(string.Format("Desktop {0}", j+1), desktopArray[j]); return desktopDictionary; } }
Copyright © 2007-2021 Binary Fortress Software
•
News
•
Discussions
•
FAQ
•
Support
•
Privacy
•
ToS
•
Get DisplayFusion Merch