Capslock doesn't work for a modifier key. Topic is solved

Get help with using AutoHotkey (v2 or newer) and its commands and hotkeys
hancre
Posts: 251
Joined: 02 Jul 2021, 20:51

Capslock doesn't work for a modifier key.

Post by hancre » 13 Mar 2024, 22:17

i've used capslock as a modifier in v1 and v2.

I found capslock doesn't work well for a few case.

Code: Select all

Capslock & a::Click
CapsLock & y::Send "{PgUp}" 
CapsLock & u::Send "{PgDn}"
CapsLock & o::Send "{Home}"  
CapsLock & p::Send "{End}" 
<Capslock & o> and <capslock & u> work well.
<Capslock & a>, <Capslock & p> and <capslock & y> don't work for movement. the key works as a toggle key for letter case.

I applied two scripts to use capslock as modifier seperately.

Code: Select all

SetStoreCapsLockMode False ; Scripts 1  
Capslock::Return  ; Scripts 2


but it shows the same result.

How can i fix the issue? Thanks for any help in advance.

Rohwedder
Posts: 7768
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: Capslock doesn't work for a modifier key.

Post by Rohwedder » 14 Mar 2024, 02:01

Hallo,
try:

Code: Select all

; type CapsLock only, to toggle CapsLock status
*CapsLock up::A_PriorKey="CapsLock"?SetCapsLockState(
"Always" (GetKeyState("CapsLock", "T")?"Off":"On")):""
; ------------- Capslock as modifier key --------
#HotIf GetKeyState("CapsLock", "P")
!+WheelUp::SoundBeep ; CapsLock + Alt + Shift + WheelUp
a::Click ; CapsLock + a
y::Send "{PgUp}"
u::Send "{PgDn}"
o::Send "{Home}"  
p::Send "{End}" 
#HotIf

lexikos
Posts: 9690
Joined: 30 Sep 2013, 04:07
Contact:

Re: Capslock doesn't work for a modifier key.

Post by lexikos » 14 Mar 2024, 04:04

Are you sure it's not a keyboard hardware limitation?

All of the hotkeys in the first post work as expected for me.

hancre
Posts: 251
Joined: 02 Jul 2021, 20:51

Re: Capslock doesn't work for a modifier key.

Post by hancre » 14 Mar 2024, 05:37

@lexikos
Thank you for your reply. ^^

I'm sure.
I tested the hotkeys in codequicktester.ahk and my main script.

In codequicktester, all the hotkeys work well.
But they don't work in my main hotkeys.

It's difficult to get the debug for my main .ahk file over 2500 lines.

Could you review the beginning of my main script?
The setting may cause the problem.

Code: Select all

#SingleInstance Force

#UseHook
#WinActivateForce
SetKeyDelay 0
SetWinDelay 0
Persistent
SetStoreCapsLockMode False

SetTitleMatchMode 2
SendMode "Input"

; set the state of the new modifier key to pressed
SetKeyDelay -1
Send "{Blind}{vkFF down}"

; wait for another key to be pressed
; KeyWait A_ThisHotkey

SetWorkingDir A_ScriptDir  ; D:\common\source\AHK

if not A_IsAdmin
	RunAs "%A_ScriptFullPath%"   ; (A_AhkPath is usually optional if the script has the .ahk extension.) You would typically check  first.


;#include Gdip_All.ahk
ToolTip "AHK V2 Action", 250, 500
       Sleep 1500
       ToolTip

^f5::reload
$+BS::SetCapsLockState !GetKeyState("CapsLock", "T") ; capslock Toggle Key
Last edited by hancre on 14 Mar 2024, 05:54, edited 1 time in total.

User avatar
boiler
Posts: 17387
Joined: 21 Dec 2014, 02:44

Re: Capslock doesn't work for a modifier key.

Post by boiler » 14 Mar 2024, 05:50

That is a huge difference from what you posted originally. You are saying that the script as you posted works for you as well. It doesn’t work within your other script which you hadn’t mentioned before and is clearly the issue.

To find the conflict, comment out the rest of your 2500 lines, verify that the new code works, then slowly add pieces in until you see what caused it to stop working. Once you isolate that, you can address it.

Are you aware that you can run multiple scripts? You don’t just need one 2500-line script that does everything. All CodeQuickTester does is run it without saving it as another file. It would also work if you saved it as a separate .ahk file.

hancre
Posts: 251
Joined: 02 Jul 2021, 20:51

Re: Capslock doesn't work for a modifier key.

Post by hancre » 14 Mar 2024, 06:00

<mention>Rohwedder</mention>

Thank you for your help.

I tested your code. But I've still got the error.

<Capslock & u> and <Capslock & o > work
<Capslock & y> and <Capslock & p> don't work.

iseahound
Posts: 1472
Joined: 13 Aug 2016, 21:04
Contact:

Re: Capslock doesn't work for a modifier key.

Post by iseahound » 14 Mar 2024, 11:54

Certain combinations of keys don't work for me on my Apple Magic Keyboard such as CapsLock + Control + /.

Try this CapsLock script:
viewtopic.php?f=96&t=125147

hancre
Posts: 251
Joined: 02 Jul 2021, 20:51

Re: Capslock doesn't work for a modifier key.

Post by hancre » 17 Mar 2024, 21:51

@iseahound
sorry. but your code also doesn't fix the issue. @.@

hancre
Posts: 251
Joined: 02 Jul 2021, 20:51

Re: Capslock doesn't work for a modifier key.  Topic is solved

Post by hancre » 31 Mar 2024, 07:24

scancode helps the hotkey work!

Code: Select all

CapsLock & sc019::Send "{End}" ; CapsLock + p : End 버튼

Post Reply

Return to “Ask for Help (v2)”