The need for this program was born from AHK being flagged as a virus, rendering the corresponding AHK script unusable as well.
Normally you could circumvent this by adding AHK to a whitelist, but this isn't always possible (ex. work laptop and/or non-admin user).
To circumvent this, we can recycle the shortcuts that windows already provides.
In particular, on Windows you can start the N-th application on the taskbar by
via Windows + N.
This program is meant to be called from the taskbar to recycle these shortcuts.
To quickly switch virtual desktops using this program you need to
- compile the project manually or via the
Makefile - create multiple shortcuts to it, each invoking it with a different argument. (e.g. the 1st invokes the .exe with 0 as argv[1], 2nd one invokes the .exe with 1 and so on, 1 for each virtual desktop you have).
- place the shortcuts in the 1st N slots in the taskbar in order by dragging them in place
Windows automatically starts the n-th program on the taskbar when you press
win+n, so by pressing win+1 it will invoke the 1st program on the taskbar.
By placing our custom shortcut there we will hook win+1 to "moving to the
1st virtual desktop"!
No need for AHK!
Drawbacks:
- our taskbar will be a bit polluted, but there should be still plenty of space for other applications.
- keybindings cannot be customized. Ask Microsoft to embed this functionality within windows. What even is the purpose of having virtual desktop without the possibility of defining a shortcut to quickly jump to a specific one quickly?
If the program takes a long time to start try editing the shortcut so that the program starts minimized.
Notice that if you edit the shortcut used to create the taskbar's shortcut you need to re-create the one on the taskbar for the modifications to propagate.