Longpress Capslock (KeyWait)

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Dragoods
Posts: 7
Joined: 17 Jul 2020, 05:16

Longpress Capslock (KeyWait)

Post by Dragoods » 17 Jul 2020, 05:40

Hi, my AHK version is v1.1.32.00

I'm trying to add more function to button "CapsLock", wanted to have mode short-press (<300ms) and long-press.

However, KeyWait method went wrong when I apply it on "CapsLock", say

Code: Select all

CapsLock::
	KeyWait, CapsLock, T1
	If ErrorLevel = 0
		MsgBox, Short-press.
	Else
		MsgBox, Long-press.
return
It seems it always leave ErrorLevel = 0, and, KeyWait doesn't expire after 1 second.

I want to know if it is a bug or is there anything potential will cause this problem.

------------------------------------------------------------------------------------------------------------------------------

I found that if I use "~CapsLock" instead, it works as I expected, but my other compound hotkey "CapsLock & X" will triger it (as '~' suggests).
User avatar
Scr1pter
Posts: 1278
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Longpress Capslock (KeyWait)

Post by Scr1pter » 17 Jul 2020, 07:27

Hi,

I made bad experience, so try the other way around:

Code: Select all

CapsLock::
	KeyWait, CapsLock, T1
	If ErrorLevel = 1
          MsgBox, Long-press
	Else
		MsgBox, short-press.
return
I preferred your way too
Short -> Long, but there was always some problem.
That's why I switched to
Long -> Short

Perhaps you should replace the MsgBox by some keysend, to see how it works in real.

Message boxes can sometimes make the impression that everything works.

Cheers!
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Dragoods
Posts: 7
Joined: 17 Jul 2020, 05:16

Re: Longpress Capslock (KeyWait)

Post by Dragoods » 17 Jul 2020, 07:35

Scr1pter wrote:
17 Jul 2020, 07:27
Hi,

I made bad experience, so try the other way around:

Code: Select all

CapsLock::
	KeyWait, CapsLock, T1
	If ErrorLevel = 1
          MsgBox, Long-press
	Else
		MsgBox, short-press.
return
I preferred your way too
Short -> Long, but there was always some problem.
That's why I switched to
Long -> Short

Perhaps you should replace the MsgBox by some keysend, to see how it works in real.

Message boxes can sometimes make the impression that everything works.

Cheers!
Thanks for reply!

Ah, I'm not sure what you mean by "Short to Long" -> "Long to Short"?
User avatar
Scr1pter
Posts: 1278
Joined: 06 Aug 2017, 08:21
Location: Germany

Re: Longpress Capslock (KeyWait)

Post by Scr1pter » 17 Jul 2020, 11:15

I mean the order.
Which condition gets checked first.
It's better readable if short comes first, then long.
But as said, I had bad experiences so I switched the conditions.

Cheers!
Please use [code][/code] when posting code!
Keyboard: Logitech G PRO - Mouse: Logitech G502 LS - OS: Windows 10 Pro 64 Bit - AHK version: 1.1.33.09
Dragoods
Posts: 7
Joined: 17 Jul 2020, 05:16

Re: Longpress Capslock (KeyWait)

Post by Dragoods » 17 Jul 2020, 11:33

Ah, I see. It was first copied from webs, and I learned how it works later. Never thought about it though.

:beer: You are so nice and vigorous, allow me say in Chinese, 干杯🍻(gan bei)!
Post Reply

Return to “Ask for Help (v1)”