Invert caps lock key

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
cl4nk
Posts: 2
Joined: 23 Aug 2017, 01:18

Invert caps lock key

23 Aug 2017, 01:30

Is there a way that I could make it so that when caps lock is enabled on my keyboard it would actually be disabled on my computer and vise versa?
cl4nk
Posts: 2
Joined: 23 Aug 2017, 01:18

Re: Invert caps lock key

23 Aug 2017, 14:40

Does anyone know??
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Invert caps lock key

23 Aug 2017, 16:09

Does that in effect mean that you want to invert the light signal: light on when CapsLock off, light off when CapsLock on?

Here are two approaches:

Code: Select all

;[KeyboardLED and related functions]
;Keyboard LED control - is possible? - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=5&t=10900&p=148776#p148776
;Keyboard LED control (capslock/numlock/scrolllock lights) - Page 2 - Scripts and Functions - AutoHotkey Community
;https://autohotkey.com/board/topic/9587-keyboard-led-control-capslocknumlockscrolllock-lights/page-2#entry446105

1:: ;toggle capslock on/off (restore capslock light to normal)
SetStoreCapslockMode, Off
SendInput, {CapsLock}
SetStoreCapslockMode, On
return

2:: ;set capslock light on
KeyboardLED(4, "on")
KeyboardLED(4, "on", 2)
return

3:: ;set capslock light off
KeyboardLED(4, "off")
KeyboardLED(4, "off", 2)
return

4:: ;toggle capslock on/off (capslock is inverted)
vState := GetKeyState("CapsLock", "T") ? "on" : "off"
SetStoreCapslockMode, Off
SendInput, {CapsLock}
SetStoreCapslockMode, On
Sleep, 100
KeyboardLED(4, vState)
KeyboardLED(4, vState, 2)
return
Note: this script would interfere with hotstrings:

Code: Select all

$a::
$b::
$c::
$d::
$e::
$f::
$g::
$h::
$i::
$j::
$k::
$l::
$m::
$n::
$o::
$p::
$q::
$r::
$s::
$t::
$u::
$v::
$w::
$x::
$y::
$z::
$+a::
$+b::
$+c::
$+d::
$+e::
$+f::
$+g::
$+h::
$+i::
$+j::
$+k::
$+l::
$+m::
$+n::
$+o::
$+p::
$+q::
$+r::
$+s::
$+t::
$+u::
$+v::
$+w::
$+x::
$+y::
$+z::
vText := SubStr(A_ThisHotkey, StrLen(A_ThisHotkey))
if InStr(A_ThisHotkey, "+")
	vCase := GetKeyState("CapsLock", "T") ? "U" : "L"
else
	vCase := GetKeyState("CapsLock", "T") ? "L" : "U"
SendInput, % Format("{:" vCase "}", vText)
return
I would welcome any feedback or alternative ideas. Thanks.
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Descolada, Rohwedder, Theda, ZhuangQu and 257 guests