sdias / win-10-virtual-desktop-enhancer

An application that enhances the Windows 10 multiple desktops feature by adding additional keyboard shortcuts and support for multiple wallpapers.
MIT License
1.77k stars 269 forks source link

Design error in shortcuts and handler #105

Open buzzer8 opened 6 years ago

buzzer8 commented 6 years ago

First of all, i'm very new to autohotkey code, its my first time to look at this kinda code. Thank you for that nice script, Its exact what i'm looking for. But you have a design error at hotkey and hotkeyhandlingi think. I'm not able to have a hotkey like Home or PgDn for switching directly to the desired screen. This is, i think so after looking to your code, because you get the number of the screen to switch to by looking at the hotkey name, for example 3 or Numpad3, so 3 is the screen to switch to. PgDn doesn't have a number attached with the desired screen, so i failed switching the screen by this or simular hotkeys.

BUT i managed to changed your code to work with hotkeys with no screen number attached in a very simple way. As i said, this is my first look at autohotkey code. So don't blame me for the way i did it. Maybe you find a better way or cleaner.

Cut of the settings file:

Desktop1=Home Desktop2=End Desktop3=PgUp Desktop4=PgDn

In the file virtual-desktop-enhancer.ahk i changed the lines (166 & 167)

setUpHotkeyWithOneSetOfModifiersAndIdentifier(hkModifiersSwitch, hkDesktopI, "OnShiftNumberedPress", "[KeyboardShortcutsModifiers] SwitchDesktop") setUpHotkeyWithOneSetOfModifiersAndIdentifier(hkModifiersMove, hkDesktopI, "OnMoveNumberedPress", "[KeyboardShortcutsModifiers] MoveWindowToDesktop")

to

setUpHotkeyWithOneSetOfModifiersAndIdentifier(hkModifiersSwitch, hkDesktopI, "OnShiftNumberedPress"i, "[KeyboardShortcutsModifiers] SwitchDesktop") setUpHotkeyWithOneSetOfModifiersAndIdentifier(hkModifiersMove, hkDesktopI, "OnMoveNumberedPress"i, "[KeyboardShortcutsModifiers] MoveWindowToDesktop")

and i added this (has to be extended to work with more than 4 screens) above line 211

OnShiftNumberedPress1() { SwitchToDesktop(1) } OnShiftNumberedPress2() { SwitchToDesktop(2) } OnShiftNumberedPress3() { SwitchToDesktop(3) } OnShiftNumberedPress4() { SwitchToDesktop(4) }

And it worked. Maybe you recode it to a maybe better cleaner way and add it to the code.

Cheers

sdias commented 6 years ago

Hi. You're absolutely right, it makes no sense as it is... Your suggestion should work fine, yes, but I would like the solution to be a bit more generic. I'll mark it as a bug so it can be picked up later. Thanks.