pmb6tz / windows-desktop-switcher

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

CTRL key 'stuck' #75

Closed cesera closed 1 year ago

cesera commented 2 years ago

I am using CTRL as the modifier key (so it works the same as my linux desktop), but most of the time I switch desktops the system acts like I keep the CTRL key pressed. To release it I just have have to press it again, but this behaviour is a bit of a pain.

Any ideas?

hpdobrica commented 2 years ago

hey @cesera @michal-murawski-90poe , did you find a workaround to this by any chance?

I even remapped my CapsLock key to F8 with PowerToys, so im technically using F8 as a trigger (as far as AHK is concerned) and im still facing the issue

Trollwut commented 1 year ago

I use the WIN key as my modifier and have the same issue. (Just to confirm your issue)

serranomorante commented 1 year ago

I would recommend just going with Dexpot.

See my comment

Trollwut commented 1 year ago

I would recommend just going with Dexpot.

See my comment

And I tested it right now and CAN NOT recommend it. (Link to software)

Dexpot looks like a "experimental virtual desktop implementation" for Windows 7. And it is.

Virtual desktops back then havent existed yet (except for sane operating systems like Linux). The idea of these programs was NOT to use real virtual desktops, but rather have ONE desktop (well, Windows only had one desktop) and having all windows on it - but then hide/show certain windows.

Dexpot seems to function exactly like that: It only shows/hide certain windows instead of switching desktops. At least it did for me, if I didnt see an option for Win 10/11 integration.

It does NOT use the native virtual desktop implementation of Win 11 and therefore fucks a bit with the system. Yes, it seems like it solves the problem, But in reality it doesnt and the experimental "virtual" desktop implementation of Dexpot has its drawbacks.

serranomorante commented 1 year ago

I would recommend just going with Dexpot. See my comment

And I tested it right now and CAN NOT recommend it. (Link to software)

Dexpot looks like a "experimental virtual desktop implementation" for Windows 7. And it is.

Virtual desktops back then havent existed yet (except for sane operating systems like Linux). The idea of these programs was NOT to use real virtual desktops, but rather have ONE desktop (well, Windows only had one desktop) and having all windows on it - but then hide/show certain windows.

Dexpot seems to function exactly like that: It only shows/hide certain windows instead of switching desktops. At least it did for me, if I didnt see an option for Win 10/11 integration.

It does NOT use the native virtual desktop implementation of Win 11 and therefore fucks a bit with the system. Yes, it seems like it solves the problem, But in reality it doesnt and the experimental "virtual" desktop implementation of Dexpot has its drawbacks.

Can you elaborate a little bit on why using the native desktop implementation from windows would be better than a virtual one? In terms of performance for example, Dexpot has been a breeze for me on Windows 10 all these months.

I don't mind to change my opinion, that's why I'm asking why native vs virtual would matter in this case. And also what could be some of the drawbacks you might think about using Dexpot.

For me it has done the following:

And these are only the things I've use. There are even more features and plugins. Solving the autohotkey stuck problem was just a small part of it. I still use autohotkey for other things. And the stuck problem was finally completely fixed for me with this script. I use it to quickly write spanish chars with accent using CapsLock+a for á or LShift+CapsLock+a for Á. I think you could use it to fix this problem.

; Thanks
; https://www.autohotkey.com/boards/viewtopic.php?t=20661

; ASCII chars
; https://homepage.cs.uri.edu/faculty/wolfe/book/Readings/R02%20Ascii/completeASCII.htm

; More chars
; https://github.com/nuj123/AutoHotKey/blob/master/misc/Typing%20Accents%20-%20Emulating%20Macs

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance Force ; The script will Reload if launched while already running
#KeyHistory 0 ; Ensures user privacy when debugging is not needed
; #Warn  ; Enable warnings to assist with detecting common errors.
; SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
; SetKeyDelay, 0

CapsLock::
    KeyWait, CapsLock
    If (A_PriorKey="CapsLock")
        SetCapsLockState, % GetKeyState("CapsLock","T") ? "Off" : "On"
Return
#If, GetKeyState("CapsLock", "P") ;Your CapsLock hotkeys go below

; á/Á
A() {
    if (A_PriorHotKey = "CapsLock" && A_ThisHotkey = "a") {
        Send {Asc 0225} ; á
    }
    else if (A_ThisHotkey = "+a") {
        Send {Asc 0193} ; Á
        SetCapsLockState,Off
    }
    else{
        MsgBox, Current shortcut is: %A_ThisHotkey%
        MsgBox, Previous shorcut was: %A_PriorHotKey%
    }
}

; é/É
E() {
    if (A_PriorHotKey = "CapsLock" && A_ThisHotkey = "e") {
        Send {Asc 0233} ; é
    }
    else if (A_ThisHotkey = "+e") {
        Send {Asc 0201} ; É
        SetCapsLockState,Off
    }
    else{
        MsgBox, Current shortcut is: %A_ThisHotkey%
        MsgBox, Previous shorcut was: %A_PriorHotKey%
    }
}

; í/Í
I() {
    if (A_PriorHotKey = "CapsLock" && A_ThisHotkey = "i") {
        Send {Asc 0237} ; í
    }
    else if (A_ThisHotkey = "+i") {
        Send {Asc 0205} ; Í
        SetCapsLockState,Off
    }
    else{
        MsgBox, Current shortcut is: %A_ThisHotkey%
        MsgBox, Previous shorcut was: %A_PriorHotKey%
    }
}

; ó/Ó
O() {
    if (A_PriorHotKey = "CapsLock" && A_ThisHotkey = "o") {
        Send {Asc 0243} ; ó
    }
    else if (A_ThisHotkey = "+o") {
        Send {Asc 0211} ; Ó
        SetCapsLockState,Off
    }
    else{
        MsgBox, Current shortcut is: %A_ThisHotkey%
        MsgBox, Previous shorcut was: %A_PriorHotKey%
    }
}

; ú/Ú
U() {
    if (A_PriorHotKey = "CapsLock" && A_ThisHotkey = "u") {
        Send {Asc 0250} ; ú
    }
    else if (A_ThisHotkey = "+u") {
        Send {Asc 0218} ; Ú
        SetCapsLockState,Off
    }
    else{
        MsgBox, Current shortcut is: %A_ThisHotkey%
        MsgBox, Previous shorcut was: %A_PriorHotKey%
    }
}

; ñ/Ñ
N() {
    if (A_PriorHotKey = "CapsLock" && A_ThisHotkey = "n") {
        Send {Asc 0241} ; ñ
    }
    else if (A_ThisHotkey = "+n") {
        Send {Asc 0209} ; Ñ
        SetCapsLockState,Off
    }
    else{
        MsgBox, Current shortcut is: %A_ThisHotkey%
        MsgBox, Previous shorcut was: %A_PriorHotKey%
    }
}

a::A()
+a::A()
e::E()
+e::E()
i::I()
+i::I()
o::O()
+o::O()
u::U()
+u::U()
n::N()
+n::N()
othervnousiainen commented 1 year ago

You can just use my fork (there's also a PR for this fix). It works fine in windows 11

Trollwut commented 1 year ago

You can just use my fork (there's also a PR for this fix). It works fine in windows 11

Thanks mate! I tested it and it does indeed work for me. Even better: I now can also move desktops, which wasnt possible before.

The "WIN key stuck error" didn't occure for now, I have to have an eye on that longer, but for now it looks very good!

Link to his PR in this repo: https://github.com/pmb6tz/windows-desktop-switcher/pull/84 Link to his fork: https://github.com/othervnousiainen/windows-desktop-switcher

Trollwut commented 1 year ago

Just came back after a few weeks:

This fix works, haven't had the stuck-key-problem since I used this.