Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTRL key 'stuck' #75

Closed
cesera opened this issue Oct 29, 2021 · 8 comments · Fixed by #84
Closed

CTRL key 'stuck' #75

cesera opened this issue Oct 29, 2021 · 8 comments · Fixed by #84

Comments

@cesera
Copy link

cesera commented Oct 29, 2021

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
Copy link

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
Copy link

Trollwut commented Nov 9, 2022

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

@serranomorante
Copy link

I would recommend just going with Dexpot.

See my comment

@Trollwut
Copy link

Trollwut commented Nov 9, 2022

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
Copy link

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:

  • Avoid the autohotkey stuck problem by not having to use autohotkey.
  • It doesn't affect the performance of my operating system at all.
  • It can automatically open a program whenever you enter/leave a specific desktop the first time or several times.
  • It can assign programs to specific desktops so they only appear on their respective desktop when you open them.
  • It allows you to have a different wallpaper for each desktop
  • It has a "widget" that shows all your desktops (by number or by the icon of the program that's currently open on that desktop) and puts an arrow on the desktop you're currently in.
  • It has rules in case you need to automate something whenever you open/focus a program window.
  • It has profiles (in case you need to switch to different setups).

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
Copy link
Contributor

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

@Trollwut
Copy link

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: #84
Link to his fork: https://github.com/othervnousiainen/windows-desktop-switcher

@Trollwut
Copy link

Just came back after a few weeks:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants