pmb6tz/windows-desktop-switcher

Cycling over all desktops while going to target one

theartkod opened this issue · 3 comments

When going from 1 desktop to 5 via shortcut, instead of toggling straight from 1 to 5, looks like appear cycling every desktop until we reach 5 (target desktop).

System: Windows 11 21H2

reproduce_issue.mp4

Yes, this is the default implementation, as it works the most robustly across systems and is least likely to break long-term.

If I remember correctly, the other solution is to use the DLL (VirtualDesktopAccessor.dll) as it contains API to "jump" straight into the target desktop.

Ideally, we could select which implementation to use in a config - if anyone wanted to develop this, I'd be happy to review it and merge it

@Elijas Hi! Thanks for quick answer!

Can you suggest, please, how I can change to this dll just for myself?

Yup!

High-level overview:

  1. This is the function that needs to be updated: _switchDesktopToTarget().
  2. Currently, it works just by sending the "switch to next desktop" keyboard shortcut until the target desktop is reached.
  3. To make it "jump", replace how it works currently with how it's done with the DLL call in this example in Ciantic/VirtualDesktopAccessor/README.

In more detail, the end result would look something similar to:

At the top of the desktop_switcher.ahk file:

GoToDesktopNumberProc := DllCall("GetProcAddress", Ptr, hVirtualDesktopAccessor, AStr, "GoToDesktopNumber", "Ptr")

In _switchDesktopToTarget function of the desktop_switcher.ahk file

DllCall(GoToDesktopNumberProc, Int, num)

There are other DllCall examples in both, the desktop_switcher.ahk file, and in the https://github.com/Ciantic/VirtualDesktopAccessor repo.

Let me know if you have any questions, and If you succeed I'd highly encourage you to release a pull request, just as a helpful example for others who would want to change to the DLL solution as well.