Every Send command sends a lot of Capslock commands also

Report problems with documented functionality
Highvoltage
Posts: 6
Joined: 14 Nov 2016, 18:36

Every Send command sends a lot of Capslock commands also

12 Apr 2018, 17:30

If i use a Send or Sendinput command, and CAPS is ON, AHK sends a lot of Capslock keydown keyups aswell!!

This is a simple script:



If Capslock is OFF, the script is working as it should:
I press F1, and it sends a key 'a'
http://prntscr.com/j4iooc

If Capslock is ON, it results in sending:
Capslock down
Capslock up
Sending character 'a' (as it should)
Capslock down
Capslock up

I grabbed a screen from a key tester http://unixpapa.com/js/testkey.html:
http://prntscr.com/j4imej

You can clearly see the two capslock instances before and after the keycode for 'a'
(I can evensee the capslock's light blinking fast when i press the key)

Windows 10 64
lexikos
Posts: 6039
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Every Send command sends a lot of Capslock commands also

12 Apr 2018, 21:52

This is by design. CapsLock is toggled in order for events it sends to have the correct result. It is then toggled back after Send, under the assumption that if you left it on, you want it to be on.
Highvoltage
Posts: 6
Joined: 14 Nov 2016, 18:36

Re: Every Send command sends a lot of Capslock commands also

13 Apr 2018, 07:27

Ahaa...
This was quite annoying cause for ages i didn't know what's wrong with my scripts.
I have a few programs that have the Capslock mapped to fnctions, and i couldn't figure out why it gets toggled by random unrelated actions.

Added this to the script header
SetStoreCapsLockMode, Off

And it soved the issue hopefully
lexikos
Posts: 6039
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Every Send command sends a lot of Capslock commands also

13 Apr 2018, 21:18

Just don't be surprised when your hotkeys send the opposite case to what you intended (because you left CapsLock on).
robodesign
Posts: 356
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: Every Send command sends a lot of Capslock commands also

01 May 2018, 15:19

Hello!

I wanted to create a new topic about an issue related to capslock and send input command, but seeing this topic, it seemed appropriate, for me, to post here the issue I discovered.

Code: [Select all] [Download] GeSHi © Codebox Plus

 #Persistent
#SingleInstance Force
#NoEnv
Hotkey, b, onKeyPress

onKeyPress() {
Text2Send := "Hello world"
SendInput, {text}%Text2Send%
}


If you press B and any other key quickly, when Capslock is ON... After 25-50 times..., and sometimes, even after pressing B and another key just once or twice.... the keyboard input gets blocked and I am no longer able to do anything with the keyboard until I restart the OS session. Closing ahk doesn't unblock the keyboard input.

In my main script, KeyPress OSD , the issue is more apparent. I just have to send a few times the text and the keyboard input remains blocked. In the provided script, you have to try it considerably more [as suggested] to nail this problem. However, I am still able to reproduce the bug within five minutes even with this sample. So, it seems that the more complex or complicated a script is, the issue gets likelier to occur.

The bug applies to Send, SendInput, SendEvent, with {raw}, {text} or without these options.

For some reason, AHK gets stuck in toggling CapsLock. I tried to fix it by using after SetCapslockState ,off.... but without luck.

Thank you .

Ps. I am using Windows 10, x64.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
robodesign
Posts: 356
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: Every Send command sends a lot of Capslock commands also

04 May 2018, 15:56

Sorry to bump this thread....

Any observations, Lexikos?
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
swagfag
Posts: 928
Joined: 11 Jan 2017, 17:59

Re: Every Send command sends a lot of Capslock commands also

04 May 2018, 16:37

https://i.imgur.com/x79agaL.gifv

cant reproduce, win 10 x64 ahk_l 1.1.28.02 w64
robodesign
Posts: 356
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: Every Send command sends a lot of Capslock commands also

04 May 2018, 16:51

You MUST press the two alternating keys utterly fast, for about a minute (or two, on the clock) , b and space (for example), in notepad, WHILE capslock is ON.... If you do it only one or twice, it's highly likely you won't reproduce it. if you don't have capslock turned on, you won't be able to reproduce the bug, ever.

And it's best not to use other keyboard tools while testing for this bug... . For example... On screen keyboards.

I admit.... It's not easy to replicate the bug, indeed.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
lexikos
Posts: 6039
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Every Send command sends a lot of Capslock commands also

05 May 2018, 00:12

The behaviour described in the OP was already confirmed to be by design, not a bug. Posting about a new issue in a topic which is effectively closed (even if it isn't marked as such) is not a great idea if you actually want someone to reply.

I tested your script, alternating keys far more than 25-50 times, and was not able to reproduce the problem.
For some reason, AHK gets stuck in toggling CapsLock.
What makes you say this?
Closing ahk doesn't unblock the keyboard input.
It is not possible for AutoHotkey to block keyboard input while it is not running.

A script could put the modifier keys in the "down" state and have them remain that way after the script exits. This might give the appearance that input is blocked because, for instance, Ctrl+Alt+Shift+A probably has no effect. This would last only until you press and release each modifier key to reset its state. However, this script does not "press" or "release" any modifier keys in the first place.

If this has anything to do with sending CapsLock down/up, I think it would have to be in combination with some third-party software or previously unheard-of OS bug.

You can use {Blind}{Text} or SetStoreCapsLockMode, Off in combination with {Text} to avoid toggling CapsLock. This might be automatic in a future version (except where there are keys preceding {Text}).
robodesign
Posts: 356
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: Every Send command sends a lot of Capslock commands also

05 May 2018, 06:12

Okay, thank you for the information.

Apologies I misjudged where to post.

However, I remain firm on the position. The provided test script, with latest ahk version, does sometimes block the keyboard input and it doesn't get unblocked even if I kill / quit ahk.

What unlocks the keyboard input is ONLY when I click on the capslock key in the windows on screen keyboard - no other key. The capslock key on my keyboard doesn't work (or any other key) .

I'll test later your suggestion. Thank you.

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.
lexikos
Posts: 6039
Joined: 30 Sep 2013, 04:07
GitHub: Lexikos

Re: Every Send command sends a lot of Capslock commands also

12 May 2018, 20:38

The latest test build improves Send {Text} to avoid toggling CapsLock if "{Text}" is at the beginning of the parameter.

So Send {Text}ab will not toggle CapsLock off/on, but Send a{Text}b will, since the effect of "a" is dependent on the state of CapsLock.

As far as I can determine, Windows does not provide an API capable of returning the keystrokes needed to produce a particular character while CapsLock is on.
robodesign
Posts: 356
Joined: 30 Sep 2017, 03:59
Facebook: marius.sucan
GitHub: mariussucan
Location: Romania
Contact:

Re: Every Send command sends a lot of Capslock commands also

13 May 2018, 04:11

Hello!

Good to hear you made improvements to this.

I just tested the idea with SetStoreCapsLockMode, off. It works, no more issues. I implemented it even in my script and it all works fine.

Thank you .

Best regards, Marius.
-------------------------
KeyPress OSD v4: GitHub or forum. (presentation video)
My home page.

Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 2 guests