About "SetCapsLockState AlwaysOff" and combination of CapsLock.

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
dsewq1LYJ
Posts: 116
Joined: 26 Aug 2014, 23:21

About "SetCapsLockState AlwaysOff" and combination of CapsLock.

07 Jun 2016, 10:52

It is pretty useful in Vim when you call the

Code: Select all

SetCapsLockState, AlwaysOff
but here comes the problem, after the call any Combinations from CapsLock stop working.

e.g.

Code: Select all

SetCapsLockState, AlwaysOff
CapsLock & Space::foo()
You can not trigger the foo() by press down CapsLock AND Space.
Uh...how to fix this issue ?
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: About "SetCapsLockState AlwaysOff" and combination of CapsLock.

07 Jun 2016, 11:55

Your example works for me..?
dsewq1LYJ
Posts: 116
Joined: 26 Aug 2014, 23:21

Re: About "SetCapsLockState AlwaysOff" and combination of CapsLock.

08 Jun 2016, 03:40

Nextron wrote:Your example works for me..?
Sorry my bad.

Call [ A.ahk ]

Code: Select all

SetCapsLockState AlwaysOff
in A.Ahk

[ B.ahk ]
and press follow hotkey in different script file.

Code: Select all

CapsLock & Space::foo()
then you can not trigger the foo().
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: About "SetCapsLockState AlwaysOff" and combination of CapsLock.

08 Jun 2016, 04:15

For me it is only blocked if SetCapsLockState AlwaysOff is called after the hotkey script. This could mean that SetCapsLockState AlwaysOff works by setting the state and then using the keyboard hook to drop all key presses. Any other non-admin hooks loaded before it wouldn't see the events either, those loaded after it or hotkeys using the same hook (same script) would.
dsewq1LYJ
Posts: 116
Joined: 26 Aug 2014, 23:21

Re: About "SetCapsLockState AlwaysOff" and combination of CapsLock.

09 Jun 2016, 10:00

Nextron wrote:For me it is only blocked if SetCapsLockState AlwaysOff is called after the hotkey script. This could mean that SetCapsLockState AlwaysOff works by setting the state and then using the keyboard hook to drop all key presses. Any other non-admin hooks loaded before it wouldn't see the events either, those loaded after it or hotkeys using the same hook (same script) would.
Should I combine those two scripts ?

Could it affect the performance of my Script ?
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: About "SetCapsLockState AlwaysOff" and combination of CapsLock.

09 Jun 2016, 10:20

I prefer to combine scripts as much as possible. Whether performance is impacted greatly depends on your use-case. I think that unless your doing really time sensitive things or interacting with the AHK process itself, you're pretty safe.
dsewq1LYJ
Posts: 116
Joined: 26 Aug 2014, 23:21

Re: About "SetCapsLockState AlwaysOff" and combination of CapsLock.

09 Jun 2016, 10:39

Nextron wrote:I prefer to combine scripts as much as possible. Whether performance is impacted greatly depends on your use-case. I think that unless your doing really time sensitive things or interacting with the AHK process itself, you're pretty safe.
Don't multiple files means mutliple threads ?

Which means it could be faster if you seperate those to mutliple ones.
User avatar
Nextron
Posts: 1391
Joined: 01 Oct 2013, 08:23
Location: Netherlands OS: Win10 AHK: Unicode x32

Re: About "SetCapsLockState AlwaysOff" and combination of CapsLock.

09 Jun 2016, 11:43

True, multiple threads may improve speed. Like I said, it greatly depend on your use-case. Having multiple scripts for simple text replacement hotkeys may decrease performance: SendInput reverts to SendEvent, multiple hooks are processed (sequentially). On the other hand, CPU heavy (compression) or slow tasks (writing/uploading files) may block execution of other tasks unless those are executed as a separate process.

In your situation it is clear: Hook of script A blocks a key which is required in script B. Either you:
• Execute script B after A.
• Run script B as admin, and A as a regular user.
• Combine those element in a single script.
A fourth option would be to not block the CapsLock key so it remains visible, but set it to off as soon as it turns on, but you'll end up with a LED that flashes on each time.
dsewq1LYJ
Posts: 116
Joined: 26 Aug 2014, 23:21

Re: About "SetCapsLockState AlwaysOff" and combination of CapsLock.

09 Jun 2016, 12:11

Nextron wrote:True, multiple threads may improve speed. Like I said, it greatly depend on your use-case. Having multiple scripts for simple text replacement hotkeys may decrease performance: SendInput reverts to SendEvent, multiple hooks are processed (sequentially). On the other hand, CPU heavy (compression) or slow tasks (writing/uploading files) may block execution of other tasks unless those are executed as a separate process.

In your situation it is clear: Hook of script A blocks a key which is required in script B. Either you:
• Execute script B after A.
• Run script B as admin, and A as a regular user.
• Combine those element in a single script.
A fourth option would be to not block the CapsLock key so it remains visible, but set it to off as soon as it turns on, but you'll end up with a LED that flashes on each time.
Thank you so much for those explnations. :D

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Bing [Bot], peter_ahk and 362 guests