Disable input of selective key in special condition

Get help with using AutoHotkey and its commands and hotkeys
tatagi
Posts: 124
Joined: 23 Aug 2018, 11:17

Disable input of selective key in special condition

20 Sep 2020, 20:21

capslock & a:: send {wheelup}

I wonder if I can disable input of a key temporarily if the last pressed key is capslock key.

I ask this because while making use of hotkey, more often than not I up capslock key first and as a result send literal {a} many many times.

to clarify, I want to achive 3 things

1. press and hold capslock + a (hotkey fires, does the scroll task)
1.1 when "a" is first released : do nothing ( hotkey expired)
1.2 when capslock is first released while "a" is kept held down : "a" key is temporarily disabled(to prevent literal "a" input)
1.3 when "a" key is up, restore "a" key as literal "a"


please help out, I am getting so frustrated haha.
tatagi
Posts: 124
Joined: 23 Aug 2018, 11:17

Re: Disable input of selective key in special condition

20 Sep 2020, 22:33

I stayed all night up in front of my laptop yesterday to turn it into the right script but I still can't make my own one..

I am losing hope :cry:
User avatar
mikeyww
Posts: 1180
Joined: 09 Sep 2014, 18:38

Re: Disable input of selective key in special condition

20 Sep 2020, 22:37

Did you try the one that I provided? If you just change the hotkey name, it might work for you.
tatagi
Posts: 124
Joined: 23 Aug 2018, 11:17

Re: Disable input of selective key in special condition

20 Sep 2020, 22:47

mikeyww wrote:
20 Sep 2020, 22:37
Did you try the one that I provided? If you just change the hotkey name, it might work for you.

Code: Select all

capslock & a::
SetTimer, Wait, -350
Send {wheeldown}
Return

Wait:
If GetKeyState("a") {
 BlockInput, On
 Sleep, 1000
 BlockInput, Off
}
SendEvent {capslock up}
Return
[Mod edit: [code][/code] tags added.]


stil don't work .. I tested how it went

1. I opened webpage with long scroll

2. cursor focusing on search bar

3. moved my cursor in the middle to start the test

4. press and hold capslock + a for like 1 sec

5. release "a"

6. result : search bar is filled with aaaaaaaaaaaaaaaaaaaaaaaaaaa (keyboard and mouse pause for 1 sec while blockinput working) aaaaaaaaaaaaaaaaaaaaaaaaaaaa resumes


holy christ, I dont effing understand how this can prevent a from sending literal a..
User avatar
mikeyww
Posts: 1180
Joined: 09 Sep 2014, 18:38

Re: Disable input of selective key in special condition

21 Sep 2020, 05:56

The following worked for me. You can adjust the timer and sleep as needed.

Code: Select all

capslock & a::
SetTimer, Wait, -350
Send {WheelDown}
Return

Wait:
If GetKeyState("a") ^ GetKeyState("CAPSLOCK") {
 BlockInput, On
 Sleep, 1000
 BlockInput, Off
}
SendEvent {capslock up}
Return

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Bodhi, Google [Bot], helming, mikeyww, songdg and 34 guests