Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed CTRL/WIN keys getting stuck #84

Merged
merged 2 commits into from
Mar 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified VirtualDesktopAccessor.dll
Binary file not shown.
15 changes: 2 additions & 13 deletions desktop_switcher.ahk
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ LastOpenedDesktop := 1
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")
global GoToDesktopNumberProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "GoToDesktopNumber", "Ptr")

; Main
SetKeyDelay, 75
Expand Down Expand Up @@ -112,19 +113,7 @@ _switchDesktopToTarget(targetDesktop)
; 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%
}
DllCall(GoToDesktopNumberProc, Int, targetDesktop-1)

; Makes the WinActivate fix less intrusive
Sleep, 50
Expand Down