ViRb3 / SylphyHornEx

📺 Virtual desktop tools for Windows 10, now with reordering
MIT License
230 stars 14 forks source link

Window swapping stopped working a while back with no errors #30

Open munael opened 3 years ago

munael commented 3 years ago

Haven't used window swapping specifically since a long while ago. Tried using it again today (got 7 virtual desktops with around 150 windows total). Doesn't work no matter what shortcut I assign. Neither when restarting.

Throughout that period, only things I can think of that changed are:

  1. Added AHK bindings with the Win/Meta key in them (but swapping doesn't work any key assignment).
  2. Installed AltDrag (again, Win key).
  3. Installed PowerToys.

Disabling each of those 3 still doesn't fix it :(

megatron0000 commented 3 years ago

I have been debugging, and found that the problem seems to be when SwapDesktops calls GetAllWindows (see relevant code below).

https://github.com/ViRb3/SylphyHornEx/blob/7d330fd89d0a3aee41d38ec70cda210aa9f9e690/source/SylphyHorn/Services/VirtualDesktopMoveService.cs#L32-L79

The problem is that GetAllWindows returns all windows (correctly) but includes a strange window from an application I have installed called Alt-Tab Terminator. This particular window generates an error on line 46, when the code calls MoveToDesktop. The image below shows this window (handle number 00010338, which I discovered by adding a LoggingService call on line 46) as seen on Spy++ (tool included in Visual Studio)

image

From the image, note that 10338 is owned by another window (30298), and 30298 is not returned by GetAllWindows (I don't know whether this is right or wrong, just noticed it).

10338 is always the first window listed by GetAllWindows (at least on my tests, maybe GetAllWindows lists them in ascending order of handle number...). So I tried to modify the code such that the first window in variable srcWindows would be skipped, and the code worked again (all the other windows were switched from one desktop to another, i.e. the swap feature worked).