From bcf6736d46437a8f310fdb786e2ac632ec632dc6 Mon Sep 17 00:00:00 2001 From: kkard2 Date: Fri, 9 May 2025 21:22:47 +0200 Subject: i didn't finish --- _windows/VirtualDesktopSwitcher/Program.cs | 43 ++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 _windows/VirtualDesktopSwitcher/Program.cs (limited to '_windows/VirtualDesktopSwitcher/Program.cs') diff --git a/_windows/VirtualDesktopSwitcher/Program.cs b/_windows/VirtualDesktopSwitcher/Program.cs new file mode 100644 index 0000000..eba2e44 --- /dev/null +++ b/_windows/VirtualDesktopSwitcher/Program.cs @@ -0,0 +1,43 @@ +using System.Runtime.InteropServices; +using WindowsDesktop; + + + +class Program +{ + [DllImport("user32.dll")] private static extern IntPtr GetForegroundWindow(); + + private static int RealIndex(int index) + { + if (index == 0) + return 9; + + return index - 1; + } + + [STAThread] + public static int Main(string[] args) + { + if (args[0] == "prepare") + { + while (VirtualDesktop.GetDesktops().Length < 10) + VirtualDesktop.Create(); + return 0; + } + if (args[0] == "switch") + { + var desktops = VirtualDesktop.GetDesktops(); + desktops[RealIndex(int.Parse(args[1]))].Switch(); + return 0; + } + if (args[0] == "move") + { + var desktops = VirtualDesktop.GetDesktops(); + var targetDesktop = desktops[RealIndex(int.Parse(args[1]))]; + VirtualDesktop.MoveToDesktop(GetForegroundWindow(), targetDesktop); + } + + return 1; + } +} + -- cgit v1.3.1