Sign in to follow this  
Followers 0
brotherhobbes

problem with capslock toggle script

5 posts in this topic

Greetings, long time lurker, first time poster. Usually I can resolve my problems by reading through posts here, but this one I thought I'd ask about.

I have a simple script that uses capslock to indicate when it enabled. Starts with capslock off. Press capslock to start it up. Pressing capslock or enter disables the main functionality. Pressing capslock again re-enables.

The problem is that sometimes the capslock light will be off, but typing results in all caps. This can be seen by pushing capslock, enter, capslock, enter. the capslock light will be off, but anything typed will be in all caps.

Perhaps someone could help me find what should be an obvious bug, I just can't see it.

; set initial values
AutoItSetOption("SendCapslockMode", 0)
Send("{CAPSLOCK off}")
HotKeySet("{CAPSLOCK}", "Toggle")
$bToggle = 0

; main loop
While 1
    If $bToggle = 1 Then
       ; functionality here
    EndIf
Wend

; called when user presses capslock
Func Toggle()
    If $bToggle = 0 Then
        $bToggle = 1
        HotKeySet("{CAPSLOCK}")
        Send("{CAPSLOCK on}")
        HotKeySet("{CAPSLOCK}", "Toggle")
        HotKeySet("{ENTER}", "Enter")
    Else
        $bToggle = 0
        HotKeySet("{CAPSLOCK}")
        Send("{CAPSLOCK off}")
        HotKeySet("{CAPSLOCK}", "Toggle")
    EndIf 
EndFunc

; called when enter is pressed, but only if toggle is on
Func Enter()
    $bToggle = 0
    HotKeySet("{CAPSLOCK}")
    Send("{CAPSLOCK off}")
    HotKeySet("{CAPSLOCK}", "Toggle")
    HotKeySet("{ENTER}")
    Send("{ENTER}")
EndFunc

Share this post


Link to post
Share on other sites



thanks josbe, works great now!

Share this post


Link to post
Share on other sites

Just a comment (not useful though :) ), but it´s possible to change the status of the

capslock if you hold down Alt, Ctrl or Shift when pressing Capslock... :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0