https://github.com/FuPeiJiang/VD.ahk Skip to content Toggle navigation Sign up * Product + Actions Automate any workflow + Packages Host and manage packages + Security Find and fix vulnerabilities + Codespaces Instant dev environments + Copilot Write better code with AI + Code review Manage code changes + Issues Plan and track work + Discussions Collaborate outside of code Explore + All features + Documentation + GitHub Skills + Blog * Solutions For + Enterprise + Teams + Startups + Education By Solution + CI/CD & Automation + DevOps + DevSecOps Resources + Customer Stories + White papers, Ebooks, Webinars + Partners * Open Source + GitHub Sponsors Fund open source developers + The ReadME Project GitHub community articles Repositories + Topics + Trending + Collections * Pricing Search or jump to... Search code, repositories, users, issues, pull requests... Search [ ] Clear Search syntax tips Provide feedback We read every piece of feedback, and take your input very seriously. [ ] [ ] Include my email address so I can be contacted Cancel Submit feedback Saved searches Use saved searches to filter your results more quickly Name [ ] Query [ ] To see all available qualifiers, see our documentation. Cancel Create saved search Sign in Sign up You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session. Dismiss alert {{ message }} FuPeiJiang / VD.ahk Public * Notifications * Fork 29 * Star 209 Windows Virtual Desktop, AutoHotkey, Windows 11 support, switch desktop, move window(wintitle) to current desktop; createDesktop, PinWindow, getCount, getDesktopNumOfWindow -> mute all windows in Virtual Desktop License MIT license 209 stars 29 forks Activity Star Notifications * Code * Issues 23 * Pull requests 4 * Discussions * Actions * Projects 0 * Security * Insights More * Code * Issues * Pull requests * Discussions * Actions * Projects * Security * Insights FuPeiJiang/VD.ahk This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository. class_VD Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags Name already in use A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch? Cancel Create 14 branches 0 tags Code * Local * Codespaces * Clone HTTPS GitHub CLI [https://github.com/F] Use Git or checkout with SVN using the web URL. [gh repo clone FuPeiJ] Work fast with our official CLI. Learn more about the CLI. * Open with GitHub Desktop * Download ZIP Sign In Required Please sign in to use Codespaces. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Launching Xcode If nothing happens, download Xcode and try again. Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @FuPeiJiang FuPeiJiang fix _tryGetValidWindow() for minimized windows; #46 ... 273edef Jun 21, 2023 fix _tryGetValidWindow() for minimized windows; #46 273edef Git stats * 147 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time notes notes/PE import directory.ah2 June 20, 2023 20:25 other examples #Include VD.ahk -> #Include %A_LineFile%\..\VD.ahk: relative to f... December 24, 2022 12:03 .gitattributes it's probably because this repo is marked as C# November 23, 2021 23:36 .gitignore ;Pin App, explanations: ("gui, add, Edit" instead of "Text" to be abl... October 28, 2021 22:20 LICENSE MIT License September 6, 2021 09:09 README.md _WinActivate_NewProcess(), SetForeGroundWindow.exe, no dependencies i... June 18, 2023 22:39 SetForeGroundWindow.exe _WinActivate_NewProcess(), SetForeGroundWindow.exe, no dependencies i... June 18, 2023 22:39 SetForegroundWindow.asm _WinActivate_NewProcess(), SetForeGroundWindow.exe, no dependencies i... June 18, 2023 22:39 VD examples.ahk gotoRelativeDesktopNum(relative_count) { ; VD.getRelativeDesktopNum (a... January 18, 2023 11:24 VD.ahk #Include VD.ahk -> #Include %A_LineFile%\..\VD.ahk: relative to f... December 24, 2022 12:03 _VD.ahk fix _tryGetValidWindow() for minimized windows; #46 June 21, 2023 12:26 View code VD.ahk: Virtual Desktop Just run the examples, everything explained inside cool fixes: if you don't use these headers, it will be slow: README.md VD.ahk: Virtual Desktop Windows 11 support, ahkv2: v2_port Just run the examples, everything explained inside * Numpad1 to go to Desktop 1 * Numpad2 to go to Desktop 2 * Numpad3 to go to Desktop 3 numpad1::VD.goToDesktopNum(1) numpad2::VD.goToDesktopNum(2) numpad3::VD.goToDesktopNum(3) * Win + x move VSCode to your current Desktop and WinActivate * Win + e move "explorer replacement program" to your current Desktop and WinActivate #x::VD.MoveWindowToCurrentDesktop("ahk_exe Code.exe ahk_class Chrome_WidgetWin_1") #e::VD.MoveWindowToCurrentDesktop("ahk_explorer ahk_exe AutoHotkey.exe") * Numpad4 to move the active window to Desktop 1 * Numpad5 to move the active window to Desktop 2 * Numpad6 to move the active window to Desktop 3 * here, I choose to follow the window numpad4::VD.MoveWindowToDesktopNum("A",1), VD.goToDesktopNum(1) numpad5::VD.MoveWindowToDesktopNum("A",2), VD.goToDesktopNum(2) numpad6::VD.MoveWindowToDesktopNum("A",3), VD.goToDesktopNum(3) numpad7::VD.MoveWindowToDesktopNum("A",1) numpad8::VD.MoveWindowToDesktopNum("A",2) numpad9::VD.MoveWindowToDesktopNum("A",3) ... ; wrapping / cycle back to first desktop when at the last ^#left::VD.goToRelativeDesktopNum(-1) ^#right::VD.goToRelativeDesktopNum(+1) ; move window to left and follow it #!left::VD.goToDesktopNum(VD.MoveWindowToRelativeDesktopNum("A", -1)) ; move window to right and follow it #!right::VD.goToDesktopNum(VD.MoveWindowToRelativeDesktopNum("A", 1)) you can remap everything --------------------------------------------------------------------- also has: * createDesktop() * PinWindow() * getCount() ;how many virtual desktops you now have * pretty much everything virtual desktop, or so I think! if there's anything missing/something you want: create an issue: I want to know what you're using it for here's quick nice example: "get desktopNum of all windows" #Include %A_LineFile%\..\..\VD.ahk foundProcesses := "" ; Make sure to get all windows from all virtual desktops DetectHiddenWindows On WinGet, id, List Loop %id% { hwnd := id%A_Index% ;VD.getDesktopNumOfWindow will filter out invalid windows desktopNum_ := VD.getDesktopNumOfWindow("ahk_id" hwnd) If (desktopNum_ > -1) ;-1 for invalid window, 0 for "Show on all desktops", 1 for Desktop 1 { WinGet, exe, ProcessName, % "ahk_id" hwnd foundProcesses .= desktopNum_ " " exe "`n" } } MsgBox % foundProcesses detect when the virtual desktop changes on occasion Windows will pull me to another desktop when I click on a notification, or I'll sometimes use the built-in Ctrl+Win+Left/Right to change desktop instead. VD.ahk/other examples/CurrentVirtualDesktopChanged RegisterDesktopNotifications.ahk Lines 9 to 14 in 73e52f9 #Include %A_LineFile%\..\..\VD.ahk VD.RegisterDesktopNotifications() VD.CurrentVirtualDesktopChanged:=Func(" CurrentVirtualDesktopChanged") CurrentVirtualDesktopChanged(desktopNum_Old, desktopNum_New) { ToolTip % desktopNum_Old ", " desktopNum_New } cool fixes: * Switching VD does not make icons (on the taskbar) flash mzomparelli/zVirtualDesktop#59 (comment) Sometimes when I switch desktop, the application that's focused on that desktop becomes highlighted in the task bar. Example: On desktop A, I have Firefox: untitled On desktop B I have Steam (note that Firefox is pinned to my task bar, which is why it's visible on this desktop): untitled2 When I switch from A to B, Steam becomes highlighted: untitled3 (It's possible to stop the blinking by explicitly selecting the blinking window with the mouse or alt+tab.) When I switch back to A, Firefox also becomes highlighted (and Steam stays visible in the taskbar because it is highlighted): untitled4 This doesn't always happen; I'm not sure if it depends on the programs or where the mouse/keyboard focus is when switching desktops. That said, it happens far too often, to the point where it defeats the point of having multiple desktops at all. (The problem isn't limited to Firefox and Steam, the same thing also happens with other programs like Explorer.) how ? WinActivate taskbar before switching and WinMinimize taskbar after arriving * Switch VD reliably works in FULLSCREEN thanks to SetTimer, pleaseSwitchDesktop, -50 --------------------------------------------------------------------- if you don't use these headers, it will be slow: #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. #SingleInstance force ListLines Off SetBatchLines -1 SendMode Input ; Recommended for new scripts due to its superior speed and reliability. SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. #KeyHistory 0 #WinActivateForce Process, Priority,, H SetWinDelay -1 SetControlDelay -1 --------------------------------------------------------------------- if you want global functions style instead of a class: eg: VD_goToDesktopNum() instead of VD.goToDesktopNum() then visit branch global_functions but it won't be updated --------------------------------------------------------------------- from https://github.com/MScholtes/VirtualDesktop/blob/ 812c321e286b82a10f8050755c94d21c4b69812f/VirtualDesktop11.cs# L161-L185 Windows 11 has more functionality, if you need: * MoveDesktop: // move current desktop to desktop in index (-> index = 0..Count-1) * SetDesktopName * SetDesktopWallpaper * GetDesktopIsPerMonitor * etc. * or anything else that's not On this list create an issue saying what function(s) you need, what you'll be using it for (I'm curious) About Windows Virtual Desktop, AutoHotkey, Windows 11 support, switch desktop, move window(wintitle) to current desktop; createDesktop, PinWindow, getCount, getDesktopNumOfWindow -> mute all windows in Virtual Desktop Topics windows winapi hotkeys autohotkey virtual-desktop Resources Readme License MIT license Activity Stars 209 stars Watchers 8 watching Forks 29 forks Report repository Releases No releases published Packages 0 No packages published Contributors 3 * @FuPeiJiang FuPeiJiang Mr. Doge * @cpbotha cpbotha Charl P. Botha * @lscobe16 lscobe16 Linus Languages * AutoHotkey 90.0% * Assembly 10.0% Footer (c) 2023 GitHub, Inc. Footer navigation * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time.