CapsLock pressing twice interferes with my AHK tool

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
likethevegetable
Posts: 81
Joined: 05 May 2021, 08:54

CapsLock pressing twice interferes with my AHK tool

Post by likethevegetable » 03 Dec 2021, 09:33

I have an AHK tool where if I press CapsLock once it does something, press it twice within a time period and it does something else. It works perfectly on my home computer. When I'm remote desktoping to my work computer, I run the same AHK script. Single press caps lock works fine. But when I double press, the menu shown below pops up, and this seems to glitch out my AHK script. I've played around with the input settings to no avail. Any suggestions?

My work computer build is 1909.
ahkQ.png
ahkQ.png (13.93 KiB) Viewed 1426 times
EDIT: Added part of the script to help

Code: Select all

CapsLock::
if (num_caps_presses > 0) ; SetTimer already started, so we log the keypress instead.
{
    num_caps_presses += 1
    return
}
num_caps_presses := 1
SetTimer, caps_presses_timer, -200 ; Wait for more presses within a 200 millisecond window.
return

caps_presses_timer:
if (num_caps_presses = 1) ; The key was pressed once.
{
    num_caps_presses := 0
    Goto BUILDGUI ; build gui
}
else if (num_caps_presses = 2) ; The key was pressed twice.
{
    Send #!{Space} ; win+alt+space, opens MS Power Toys Run
}
num_caps_presses := 0
return


BUILDGUI:
etc etc...
Last edited by likethevegetable on 03 Dec 2021, 10:30, edited 1 time in total.

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: CapsLock pressing twice interferes with my AHK tool

Post by mikeyww » 03 Dec 2021, 09:58

Feel free to post your script for feedback about it.

likethevegetable
Posts: 81
Joined: 05 May 2021, 08:54

Re: CapsLock pressing twice interferes with my AHK tool

Post by likethevegetable » 03 Dec 2021, 09:59

mikeyww wrote:
03 Dec 2021, 09:58
Feel free to post your script for feedback about it.
I don't think this is a script problem... More of a Windows problem.

likethevegetable
Posts: 81
Joined: 05 May 2021, 08:54

Re: CapsLock pressing twice interferes with my AHK tool

Post by likethevegetable » 03 Dec 2021, 10:32

Editted OG post to show excerpt of code. Note that I run the script on my home computer and remote desktop simulataneously. I don't have an issue on my home computer. If I chane the 2-press Send (say comment it out), the issue persists.

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: CapsLock pressing twice interferes with my AHK tool

Post by mikeyww » 03 Dec 2021, 11:53

How about the following?

Code: Select all

CapsLock Up::
SetTimer, Kappy, -300
kap++
Return
Kappy:
Switch kap {
 Case 1: SendInput Single`n
 Case 2: SendInput Double`n
}
kap =
Return
This is very similar to yours. I did not see any popups.

I'm not sure how Win+Alt+Space is processed at your end. I would also suggest using Gosub instead of Goto if that flow also works.

Debugging the rest of the script is impossible since it is not provided here.

likethevegetable
Posts: 81
Joined: 05 May 2021, 08:54

Re: CapsLock pressing twice interferes with my AHK tool

Post by likethevegetable » 04 Dec 2021, 08:17

The issue persists. There is nothing wrong with my script, I definitely think this is a Windows setting issue.

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: CapsLock pressing twice interferes with my AHK tool

Post by mikeyww » 04 Dec 2021, 08:37

You may want to have a look at what keyboard shortcut you have set to change the input language.

Code: Select all

Run, % A_WinDir "\System32\rundll32.exe " 
     . "Shell32.dll,Control_RunDLL input.dll,,{C07337D3-DB2C-4D0B-9A93-B722A6C106E2}"
WinWaitActive, Text Services ahk_class #32770 ahk_exe rundll32.exe,, 5
Send % ErrorLevel ? "" : "^{Tab}"

likethevegetable
Posts: 81
Joined: 05 May 2021, 08:54

Re: CapsLock pressing twice interferes with my AHK tool

Post by likethevegetable » 04 Dec 2021, 11:21

Thanks for sharing that. I previously looked through it and tried all of the settings. Additionally, I see no mention of double-pressing CapsLock.

Do you think it could be a possibility that the keyboard connected to my remote desktop could be messing things up?

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: CapsLock pressing twice interferes with my AHK tool

Post by mikeyww » 04 Dec 2021, 11:24

That would seem most unusual, but testing this with another keyboard is probably fast and easy. I wonder if you have any other keyboard or shortcut manager that is acting concurrently.

1. Did you try exiting your own script, and just running the one that is posted here (above), with no other code, and no other scripts running?

2. Furthermore, does the problem occur when no scripts are running?

likethevegetable
Posts: 81
Joined: 05 May 2021, 08:54

Re: CapsLock pressing twice interferes with my AHK tool

Post by likethevegetable » 04 Dec 2021, 14:39

Yes; I've tried pressing double caps with the script exited before I even posted to see if my script was the culprit, hence I believe there's some other shortcut manager behind the scenes.

User avatar
mikeyww
Posts: 26588
Joined: 09 Sep 2014, 18:38

Re: CapsLock pressing twice interferes with my AHK tool

Post by mikeyww » 04 Dec 2021, 14:59

OK. If you have the problem when you boot your computer and have no scripts running or previously run, then this problem has nothing to do with AutoHotkey. Would check your tray for resident utilities.

braunbaer
Posts: 478
Joined: 22 Feb 2016, 10:49

Re: CapsLock pressing twice interferes with my AHK tool

Post by braunbaer » 04 Dec 2021, 15:34

If your remote computer is a notebook, the firmware of the notebook might interfere. In that case, I don't think you can do anything about it. If the firmware catches a key or a key combination, windows does not even see that the key was pressed.

likethevegetable
Posts: 81
Joined: 05 May 2021, 08:54

Re: CapsLock pressing twice interferes with my AHK tool

Post by likethevegetable » 05 Dec 2021, 11:21

Although this arguably off topic, I should add the resolution for completenness. Under:

Settings->Time & Language->Region: Set both country and format to Canada

Then under:

Settings->Time & Language->Language: Select Canada, remove USA.

Note: the ENG taskbar icon disappeared after.

Post Reply

Return to “Ask for Help (v1)”