top | item 42876203

(no title)

17 points| Tommix11 | 1 year ago

discuss

order

Someone|1 year ago

I think an AutoHotKey script could do that (if it runs on Windows 11. I couldn’t easily find that on its site). Approach would be:

- in a “caps lock key pressed” handler, set a timer (https://www.autohotkey.com/docs/v2/lib/SetTimer.htm) that runs every ten seconds

- in that timer, check the value of A_TimeIdleKeyboard (https://www.autohotkey.com/docs/v2/Variables.htm#TimeIdleKey...)

- if it’s too large, call SetCapsLockState (https://www.autohotkey.com/docs/v2/lib/SetNumScrollCapsLockS...) and stop the timer

- otherwise, compute a new ideal delay from the desired run interval and A_TimeIdleKeyboard, and update the time interval

You also wail want to prevent starting multiple timers if you enable caps lock multiple times.

mmh0000|1 year ago

Here's an AHK script I've had since 2007 (omg, I'm too old). Adds a delay (press-and-hold to enable/disable) to capslock. Not exactly what you want, but I loved it and it should be easy to modify to do what you want:

  CAPSLKTOOLTIP:
  ToolTip,
  SetTimer,CAPSLKTOOLTIP,Off
  Return
  
  SetTimer,CAPSLKTOOLTIP,1500
  SetTimer,CAPSLKTOOLTIP,Off
  
  CapsLock::
  counter := 0
  Loop,20
  {
   Sleep, 40
   counter++
   GetKeyState,state,CapsLock,P
   If state=U
    Break
  
   If counter >= 20
   {
    counter := 0
    GetKeyState,state,CapsLock,T
    If state=D
    {
     ToolTip,Caps Lock Off
     SetCapsLockState,Off
    }
    Else
    {
     ToolTip,Caps Lock On
     SetCapsLockState,On
  
    }
    keyWait, Capslock, U
    SetTimer,CAPSLKTOOLTIP,On
    Continue
   }
  }
  Return

Tommix11|1 year ago

Thank you, I'll check it out.