windows-desktop-switcher

An AutoHotKey script for Windows that lets a user change virtual desktops by pressing CapsLock + <num>. (by pmb6tz)

Windows-desktop-switcher Alternatives

Similar projects and alternatives to windows-desktop-switcher

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a better windows-desktop-switcher alternative or higher similarity.

windows-desktop-switcher reviews and mentions

Posts with mentions or reviews of windows-desktop-switcher. We have used some of these posts to build our list of alternatives and similar projects. The last one was on 2022-10-21.
  • Switch between Virtual Desktops with Keyboard while using Remote Desktop
    1 project | /r/WindowsHelp | 27 May 2023
    If you wanna use autohotkey, I personally use this script but heavily modify it to use my own keybinds: https://github.com/pmb6tz/windows-desktop-switcher
  • I'm trying to convert this virtual desktop switcher script to v2, it's the only thing holding be back to v1 right now
    1 project | /r/AutoHotkey | 10 Apr 2023
    #SingleInstance Force ; The script will Reload if launched while already running KeyHistory(0) ; Ensures user privacy when debugging is not needed SetWorkingDir(A_ScriptDir) ; Ensures a consistent starting directory SendMode("Input") ; Recommended for new scripts due to its superior speed and reliability ; Globals DesktopCount := 2 ; Windows starts with 2 desktops at boot CurrentDesktop := 1 ; Desktop count is 1-indexed (Microsoft numbers them this way) LastOpenedDesktop := 1 ; DLL hVirtualDesktopAccessor := DllCall("LoadLibrary", "Str", A_ScriptDir . "\VirtualDesktopAccessor.dll", "Ptr") global IsWindowOnDesktopNumberProc := DllCall("GetProcAddress", "Ptr", hVirtualDesktopAccessor, "AStr", "IsWindowOnDesktopNumber", "Ptr") global MoveWindowToDesktopNumberProc := DllCall("GetProcAddress", "Ptr", hVirtualDesktopAccessor, "AStr", "MoveWindowToDesktopNumber", "Ptr") ; Main SetKeyDelay(75) mapDesktopsFromRegistry() OutputDebug("[loading] desktops: " DesktopCount " current: " CurrentDesktop) ;#Include %A_ScriptDir%\user_config.ahk return ; ; This function examines the registry to build an accurate list of the current virtual desktops and which one we're currently on. ; List of desktops appears to be in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops ; On Windows 11 the current desktop UUID appears to be in the same location ; On previous versions in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SessionInfo\1\VirtualDesktops ; mapDesktopsFromRegistry() { global CurrentDesktop, DesktopCount ; Get the current desktop UUID. Length should be 32 always, but there's no guarantee this couldn't change in a later Windows release so we check. IdLength := 32 SessionId := getSessionId() if (SessionId) { CurrentDesktopId := RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops", "CurrentVirtualDesktop") if ErrorLevel { CurrentDesktopId := RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SessionInfo\" SessionId "\VirtualDesktops", "CurrentVirtualDesktop") } if (CurrentDesktopId) { IdLength := StrLen(CurrentDesktopId) } } ; Get a list of the UUIDs for all virtual desktops on the system DesktopList := RegRead("HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops", "VirtualDesktopIDs") if (DesktopList) { DesktopListLength := StrLen(DesktopList) ; Figure out how many virtual desktops there are DesktopCount := floor(DesktopListLength / IdLength) } else { DesktopCount := 1 } ; Parse the REG_DATA string that stores the array of UUID's for virtual desktops in the registry. i := 0 while (CurrentDesktopId and i < DesktopCount) { StartPos := (i * IdLength) + 1 DesktopIter := SubStr(DesktopList, (StartPos)<1 ? (StartPos)-1 : (StartPos), IdLength) OutputDebug("The iterator is pointing at " DesktopIter " and count is " i ".") ; Break out if we find a match in the list. If we didn't find anything, keep the ; old guess and pray we're still correct :-D. if (DesktopIter = CurrentDesktopId) { CurrentDesktop := i + 1 OutputDebug("Current desktop number is " CurrentDesktop " with an ID of " DesktopIter ".") break } i++ } } ; ; This functions finds out ID of current session. ; getSessionId() { ProcessId := DllCall("GetCurrentProcessId", "UInt") if ErrorLevel { OutputDebug("Error getting current process id: " ErrorLevel) return } OutputDebug("Current Process Id: " ProcessId) DllCall("ProcessIdToSessionId", "UInt", ProcessId, "UInt*", &SessionId) if ErrorLevel { OutputDebug("Error getting session id: " ErrorLevel) return } OutputDebug("Current Session Id: " SessionId) return SessionId } _switchDesktopToTarget(targetDesktop) { ; Globals variables should have been updated via updateGlobalVariables() prior to entering this function global CurrentDesktop, DesktopCount, LastOpenedDesktop ; Don't attempt to switch to an invalid desktop if (targetDesktop > DesktopCount || targetDesktop < 1 || targetDesktop == CurrentDesktop) { OutputDebug("[invalid] target: " targetDesktop " current: " CurrentDesktop) return } LastOpenedDesktop := CurrentDesktop ; Fixes the issue of active windows in intermediate desktops capturing the switch shortcut and therefore delaying or stopping the switching sequence. This also fixes the flashing window button after switching in the taskbar. More info: https://github.com/pmb6tz/windows-desktop-switcher/pull/19 WinActivate("ahk_class Shell_TrayWnd") ; Go right until we reach the desktop we want while(CurrentDesktop < targetDesktop) { Send("{LWin down}{LCtrl down}{Right down}{LWin up}{LCtrl up}{Right up}") CurrentDesktop++ OutputDebug("[right] target: " targetDesktop " current: " CurrentDesktop) } ; Go left until we reach the desktop we want while(CurrentDesktop > targetDesktop) { Send("{LWin down}{LCtrl down}{Left down}{Lwin up}{LCtrl up}{Left up}") CurrentDesktop-- OutputDebug("[left] target: " targetDesktop " current: " CurrentDesktop) } ; Makes the WinActivate fix less intrusive Sleep(50) focusTheForemostWindow(targetDesktop) } updateGlobalVariables() { ; Re-generate the list of desktops and where we fit in that. We do this because ; the user may have switched desktops via some other means than the script. mapDesktopsFromRegistry() } switchDesktopByNumber(targetDesktop) { global CurrentDesktop, DesktopCount updateGlobalVariables() _switchDesktopToTarget(targetDesktop) } switchDesktopToLastOpened() { global CurrentDesktop, DesktopCount, LastOpenedDesktop updateGlobalVariables() _switchDesktopToTarget(LastOpenedDesktop) } switchDesktopToRight() { global CurrentDesktop, DesktopCount updateGlobalVariables() _switchDesktopToTarget(CurrentDesktop == DesktopCount ? 1 : CurrentDesktop + 1) } switchDesktopToLeft() { global CurrentDesktop, DesktopCount updateGlobalVariables() _switchDesktopToTarget(CurrentDesktop == 1 ? DesktopCount : CurrentDesktop - 1) } focusTheForemostWindow(targetDesktop) { foremostWindowId := getForemostWindowIdOnDesktop(targetDesktop) if isWindowNonMinimized(foremostWindowId) { WinActivate("ahk_id " foremostWindowId) } } isWindowNonMinimized(windowId) { MMX := WinGetMinMax("ahk_id " windowId) return MMX != -1 } getForemostWindowIdOnDesktop(n) { n := n - 1 ; Desktops start at 0, while in script it's 1 ; winIDList contains a list of windows IDs ordered from the top to the bottom for each desktop. owinIDList := WinGetlist(,,,) awinIDList := Array() winIDList := owinIDList.Length For v in owinIDList { awinIDList.Push(v) } Loop awinIDList.Length { windowID := awinIDList[A_Index] windowIsOnDesktop := DllCall(IsWindowOnDesktopNumberProc, "UInt", windowID, "UInt", n) ; Select the first (and foremost) window which is in the specified desktop. if (windowIsOnDesktop == 1) { return windowID } } } MoveCurrentWindowToDesktop(desktopNumber) { activeHwnd := WinGetID("A") DllCall(MoveWindowToDesktopNumberProc, "UInt", activeHwnd, "UInt", desktopNumber - 1) switchDesktopByNumber(desktopNumber) } MoveCurrentWindowToRightDesktop() { global CurrentDesktop, DesktopCount updateGlobalVariables() activeHwnd := WinGetID("A") DllCall(MoveWindowToDesktopNumberProc, "UInt", activeHwnd, "UInt", (CurrentDesktop == DesktopCount ? 1 : CurrentDesktop + 1) - 1) _switchDesktopToTarget(CurrentDesktop == DesktopCount ? 1 : CurrentDesktop + 1) } MoveCurrentWindowToLeftDesktop() { global CurrentDesktop, DesktopCount updateGlobalVariables() activeHwnd := WinGetID("A") DllCall(MoveWindowToDesktopNumberProc, "UInt", activeHwnd, "UInt", (CurrentDesktop == 1 ? DesktopCount : CurrentDesktop - 1) - 1) _switchDesktopToTarget(CurrentDesktop == 1 ? DesktopCount : CurrentDesktop - 1) } ; ; This function creates a new virtual desktop and switches to it ; createVirtualDesktop() { global CurrentDesktop, DesktopCount Send("#^d") DesktopCount++ CurrentDesktop := DesktopCount OutputDebug("[create] desktops: " DesktopCount " current: " CurrentDesktop) } ; ; This function deletes the current virtual desktop ; deleteVirtualDesktop() { global CurrentDesktop, DesktopCount, LastOpenedDesktop Send("#^{F4}") if (LastOpenedDesktop >= CurrentDesktop) { LastOpenedDesktop-- } DesktopCount-- CurrentDesktop-- OutputDebug("[delete] desktops: " DesktopCount " current: " CurrentDesktop) } ; Switcher Options ; ----------------------------------------------- ^!1::switchDesktopByNumber(1) ^!2::switchDesktopByNumber(2) ^!3::switchDesktopByNumber(3) ^!4::switchDesktopByNumber(4) ^!5::switchDesktopByNumber(5) ^!6::switchDesktopByNumber(6) ^!7::switchDesktopByNumber(7) ^!8::switchDesktopByNumber(8) ^!9::switchDesktopByNumber(9) ^!Numpad1::switchDesktopByNumber(1) ^!Numpad2::switchDesktopByNumber(2) ^!Numpad3::switchDesktopByNumber(3) ^!Numpad4::switchDesktopByNumber(4) ^!Numpad5::switchDesktopByNumber(5) ^!Numpad6::switchDesktopByNumber(6) ^!Numpad7::switchDesktopByNumber(7) ^!Numpad8::switchDesktopByNumber(8) ^!Numpad9::switchDesktopByNumber(9) ^!n::switchDesktopToRight() ^!p::switchDesktopToLeft() ^!s::switchDesktopToRight() ^!a::switchDesktopToLeft() ^!tab::switchDesktopToLastOpened() ^!c::createVirtualDesktop() ^!d::deleteVirtualDesktop() ^#Ins::MoveCurrentWindowToDesktop(1) ^#PgUp::MoveCurrentWindowToDesktop(2) ^#Home::MoveCurrentWindowToDesktop(3) ^#End::MoveCurrentWindowToDesktop(4) ^#PgDn::MoveCurrentWindowToDesktop(5) ^#F6::MoveCurrentWindowToDesktop(6) ^#F7::MoveCurrentWindowToDesktop(7) ^#F8::MoveCurrentWindowToDesktop(8) ^#F9::MoveCurrentWindowToDesktop(9) ^#Numpad1::MoveCurrentWindowToDesktop(1) ^#Numpad2::MoveCurrentWindowToDesktop(2) ^#Numpad3::MoveCurrentWindowToDesktop(3) ^#Numpad4::MoveCurrentWindowToDesktop(4) ^#Numpad5::MoveCurrentWindowToDesktop(5) ^#Numpad6::MoveCurrentWindowToDesktop(6) ^#Numpad7::MoveCurrentWindowToDesktop(7) ^#Numpad8::MoveCurrentWindowToDesktop(8) ^#Numpad9::MoveCurrentWindowToDesktop(9) ^#Right::MoveCurrentWindowToRightDesktop() ^#Left::MoveCurrentWindowToLeftDesktop() ; === INSTRUCTIONS === ; Additional alternative shortcut for moving current window to left or right desktop (ctrl+shift+Win+left/right) ; === END OF INSTRUCTIONS === ; ^#+Right::MoveCurrentWindowToRightDesktop() ; ^#+Left::MoveCurrentWindowToLeftDesktop()
  • Trying to get my calculator button to start the calc or focus it if an instance is already running
    1 project | /r/AutoHotkey | 8 Apr 2023
    But I guess I need to do some research into how to do that, or how to convert this desktop switcher script into v2.
  • i'm using a script which switches virtual desktop, but I dont wan't taskbar to display?
    2 projects | /r/AutoHotkey | 21 Oct 2022
    #SingleInstance Force ; The script will Reload if launched while already running #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases #KeyHistory 0 ; Ensures user privacy when debugging is not needed SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory SendMode Input ; Recommended for new scripts due to its superior speed and reliability ; Globals DesktopCount := 2 ; Windows starts with 2 desktops at boot CurrentDesktop := 1 ; Desktop count is 1-indexed (Microsoft numbers them this way) LastOpenedDesktop := 1 ; DLL hVirtualDesktopAccessor := DllCall("LoadLibrary", "Str", A_ScriptDir . "\VirtualDesktopAccessor.dll", "Ptr") global IsWindowOnDesktopNumberProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "IsWindowOnDesktopNumber", "Ptr") global MoveWindowToDesktopNumberProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "MoveWindowToDesktopNumber", "Ptr") ; Main SetKeyDelay, 75 mapDesktopsFromRegistry() OutputDebug, [loading] desktops: %DesktopCount% current: %CurrentDesktop% #Include %A_ScriptDir%\user_config.ahk return ; ; This function examines the registry to build an accurate list of the current virtual desktops and which one we're currently on. ; Current desktop UUID appears to be in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SessionInfo\1\VirtualDesktops ; List of desktops appears to be in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops ; mapDesktopsFromRegistry() { global CurrentDesktop, DesktopCount ; Get the current desktop UUID. Length should be 32 always, but there's no guarantee this couldn't change in a later Windows release so we check. IdLength := 32 SessionId := getSessionId() if (SessionId) { RegRead, CurrentDesktopId, HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\SessionInfo\%SessionId%\VirtualDesktops, CurrentVirtualDesktop if (CurrentDesktopId) { IdLength := StrLen(CurrentDesktopId) } } ; Get a list of the UUIDs for all virtual desktops on the system RegRead, DesktopList, HKEY_CURRENT_USER, SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VirtualDesktops, VirtualDesktopIDs if (DesktopList) { DesktopListLength := StrLen(DesktopList) ; Figure out how many virtual desktops there are DesktopCount := floor(DesktopListLength / IdLength) } else { DesktopCount := 1 } ; Parse the REG_DATA string that stores the array of UUID's for virtual desktops in the registry. i := 0 while (CurrentDesktopId and i < DesktopCount) { StartPos := (i * IdLength) + 1 DesktopIter := SubStr(DesktopList, StartPos, IdLength) OutputDebug, The iterator is pointing at %DesktopIter% and count is %i%. ; Break out if we find a match in the list. If we didn't find anything, keep the ; old guess and pray we're still correct :-D. if (DesktopIter = CurrentDesktopId) { CurrentDesktop := i + 1 OutputDebug, Current desktop number is %CurrentDesktop% with an ID of %DesktopIter%. break } i++ } } ; ; This functions finds out ID of current session. ; getSessionId() { ProcessId := DllCall("GetCurrentProcessId", "UInt") if ErrorLevel { OutputDebug, Error getting current process id: %ErrorLevel% return } OutputDebug, Current Process Id: %ProcessId% DllCall("ProcessIdToSessionId", "UInt", ProcessId, "UInt*", SessionId) if ErrorLevel { OutputDebug, Error getting session id: %ErrorLevel% return } OutputDebug, Current Session Id: %SessionId% return SessionId } _switchDesktopToTarget(targetDesktop) { ; Globals variables should have been updated via updateGlobalVariables() prior to entering this function global CurrentDesktop, DesktopCount, LastOpenedDesktop ; Don't attempt to switch to an invalid desktop if (targetDesktop > DesktopCount || targetDesktop < 1 || targetDesktop == CurrentDesktop) { OutputDebug, [invalid] target: %targetDesktop% current: %CurrentDesktop% return } LastOpenedDesktop := CurrentDesktop ; Fixes the issue of active windows in intermediate desktops capturing the switch shortcut and therefore delaying or stopping the switching sequence. This also fixes the flashing window button after switching in the taskbar. More info: https://github.com/pmb6tz/windows-desktop-switcher/pull/19 WinActivate, ahk_class Shell_TrayWnd ; Go right until we reach the desktop we want while(CurrentDesktop < targetDesktop) { Send {LWin down}{LCtrl down}{Right down}{LWin up}{LCtrl up}{Right up} CurrentDesktop++ OutputDebug, [right] target: %targetDesktop% current: %CurrentDesktop% } ; Go left until we reach the desktop we want while(CurrentDesktop > targetDesktop) { Send {LWin down}{LCtrl down}{Left down}{Lwin up}{LCtrl up}{Left up} CurrentDesktop-- OutputDebug, [left] target: %targetDesktop% current: %CurrentDesktop% } ; Makes the WinActivate fix less intrusive Sleep, 50 focusTheForemostWindow(targetDesktop) } updateGlobalVariables() { ; Re-generate the list of desktops and where we fit in that. We do this because ; the user may have switched desktops via some other means than the script. mapDesktopsFromRegistry() } switchDesktopByNumber(targetDesktop) { global CurrentDesktop, DesktopCount updateGlobalVariables() _switchDesktopToTarget(targetDesktop) } switchDesktopToLastOpened() { global CurrentDesktop, DesktopCount, LastOpenedDesktop updateGlobalVariables() _switchDesktopToTarget(LastOpenedDesktop) } switchDesktopToRight() { global CurrentDesktop, DesktopCount updateGlobalVariables() _switchDesktopToTarget(CurrentDesktop == DesktopCount ? 1 : CurrentDesktop + 1) } switchDesktopToLeft() { global CurrentDesktop, DesktopCount updateGlobalVariables() _switchDesktopToTarget(CurrentDesktop == 1 ? DesktopCount : CurrentDesktop - 1) } focusTheForemostWindow(targetDesktop) { foremostWindowId := getForemostWindowIdOnDesktop(targetDesktop) if isWindowNonMinimized(foremostWindowId) { WinActivate, ahk_id %foremostWindowId% } } isWindowNonMinimized(windowId) { WinGet MMX, MinMax, ahk_id %windowId% return MMX != -1 } getForemostWindowIdOnDesktop(n) { n := n - 1 ; Desktops start at 0, while in script it's 1 ; winIDList contains a list of windows IDs ordered from the top to the bottom for each desktop. WinGet winIDList, list Loop % winIDList { windowID := % winIDList%A_Index% windowIsOnDesktop := DllCall(IsWindowOnDesktopNumberProc, UInt, windowID, UInt, n) ; Select the first (and foremost) window which is in the specified desktop. if (windowIsOnDesktop == 1) { return windowID } } } MoveCurrentWindowToDesktop(desktopNumber) { WinGet, activeHwnd, ID, A DllCall(MoveWindowToDesktopNumberProc, UInt, activeHwnd, UInt, desktopNumber - 1) switchDesktopByNumber(desktopNumber) } ; ; This function creates a new virtual desktop and switches to it ; createVirtualDesktop() { global CurrentDesktop, DesktopCount Send, #^d DesktopCount++ CurrentDesktop := DesktopCount OutputDebug, [create] desktops: %DesktopCount% current: %CurrentDesktop% } ; ; This function deletes the current virtual desktop ; deleteVirtualDesktop() { global CurrentDesktop, DesktopCount, LastOpenedDesktop Send, #^{F4} if (LastOpenedDesktop >= CurrentDesktop) { LastOpenedDesktop-- } DesktopCount-- CurrentDesktop-- OutputDebug, [delete] desktops: %DesktopCount% current: %CurrentDesktop% }
  • Is there a way to jump to a specific virtual desktop?
    1 project | /r/Windows11 | 15 May 2022
    There is actually one and I'm using it for months. It works on windows 10 and windows 11. You just need to download autohotkey. Head on to this github link: https://github.com/pmb6tz/windows-desktop-switcher.
  • Is it possible to have an automatic split screen divide on a single screen?
    1 project | /r/Windows11 | 1 Mar 2022
    You can try desktop switcher which made my virtual desktop experience efficient. It lets you quickly jump from desktop 1 to desktop 5 with just keyboard shortcut. https://github.com/pmb6tz/windows-desktop-switcher
  • Virtual Desktop Switcher works with Windows 11
    2 projects | /r/Windows11 | 28 Feb 2022
    I just updated to windows 11 yesterday. Most of my programs and autohotkey scripts works except the windows desktop switcher. Moving app windows to another desktop doesn't work. I searched around the github and found that some people also experience this problem. Then I found this comment. I just downloaded the file and replace it to the parent file of the AHK Script and it works!
  • Be more efficient using virtual desktops with this autohotkey script
    1 project | /r/Windows10 | 28 Feb 2022
    windows-desktop-switcher
  • Add taskbar desktop switcher hover style and animation to taskbar apps
    1 project | /r/Windows11 | 9 Jan 2022
    I found this cool project on github which let you switch different virtual desktop quickly. https://github.com/pmb6tz/windows-desktop-switcher
  • Window does not auto-focus to foreground upon changing virtual desktops
    3 projects | /r/AutoHotkey | 16 Nov 2021
    I use this amazing script to assign a Virtual Desktop number to a key command so that I can quickly switch to Desktop 2 using Alt+2, for example. However, I'm having a problem where, after pressing the key command to switch Desktops, the only window on that desktop is in the BACKGROUND and requires alt+tab or clicking on the window to bring it to the foreground.
  • A note from our sponsor - SaaSHub
    www.saashub.com | 2 May 2024
    SaaSHub helps you find the best software and product alternatives Learn more →

Stats

Basic windows-desktop-switcher repo stats
10
1,147
2.8
3 months ago

pmb6tz/windows-desktop-switcher is an open source project licensed under MIT License which is an OSI approved license.

The primary programming language of windows-desktop-switcher is AutoHotkey.


Sponsored
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com