pmb6tz / windows-desktop-switcher

An AutoHotKey script for Windows that lets a user change virtual desktops by pressing CapsLock + <num>.
MIT License
1.21k stars 229 forks source link

switchDesktopToLastOpened() doesn't always work correctly #70

Open EdwinVanRooij opened 3 years ago

EdwinVanRooij commented 3 years ago

I'm using the default key binding: CapsLock & tab::switchDesktopToLastOpened().

Steps to reproduce:

Now it's not hard to see what's happening here, the variable LastOpenedDesktop is only set in _switchDesktopToTarget (LastOpenedDesktop := CurrentDesktop). Because of this, any other way of moving to another desktop will not register into the variable LastOpenedDesktop, thus leaving value 2 in LastOpenedDesktop, even though I'm currently at desktop 2 and 1 was my previous desktop.

tl;dr: this program assumes it is in complete control over switching desktops, leading to broken functionality

I've thought about this for a while, but I haven't been able to come up with a clean solution.

EdwinVanRooij commented 3 years ago

Update: For anyone else experiencing this bug, I have found a way to "deal" with it. It's not a solution, but rather something to deal with it in most cases. I added a check to the script, it checks whether I'm currently on the LastOpenedDesktop. If I am, but I pressed the shortcut to switchDesktopToLastOpened(), it will always move me to desktop number 1 (hard coded).

99% of the times I'm experiencing this bug, I want to go from some desktop where I got through messaging (which is usually at desktop 2), back to my working desktop (which is desktop 1).

itfootman commented 2 years ago

I am experiencing this bug, any solution ?

itfootman commented 2 years ago

I think switching desktop by clicking the notify icon of status bar is not recorded by switchDesktopByNumber, so it can not restore to last opened desktop.