Jump to content

Hotkey causing ctrl key to be locked down (I think!)


 Share

Recommended Posts

I have a problem with a program that uses a lot of hotkeys. Every now and again, pressing one of them seems to leave the ctrl key locked down, even when I exit the program. There's something here here that sounds vaguely similar, though I couldn't really follow the discussion or solution.

I wondered if anyone has had the same problem, or knows of a way to prevent it happening?

Thanks!

Link to comment
Share on other sites

I have a problem with a program that uses a lot of hotkeys. Every now and again, pressing one of them seems to leave the ctrl key locked down, even when I exit the program. There's something here here that sounds vaguely similar, though I couldn't really follow the discussion or solution.

I wondered if anyone has had the same problem, or knows of a way to prevent it happening?

Thanks!

Do you have any Send functioons? In particular, do you have a Send which is triggered by the HotKey?
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

Do you have any Send functioons? In particular, do you have a Send which is triggered by the HotKey?

Yes, I have cut, copy and paste functions, such as:

Func EditCut()

Send("^x")

EndFunc

These are not run using the Windows hotkeys, but are occasionally called when required by other functions.

There's also a macro function that reads a succession of key strokes from a text file and Sends each one. This can be run using ctrl-shift x, and will normally contain at least one of the hotkeys I've defined.

Link to comment
Share on other sites

Yes, I have cut, copy and paste functions, such as:

Func EditCut()

Send("^x")

EndFunc

These are not run using the Windows hotkeys, but are occasionally called when required by other functions.

There's also a macro function that reads a succession of key strokes from a text file and Sends each one. This can be run using ctrl-shift x, and will normally contain at least one of the hotkeys I've defined.

If you use Send in a script and you have a problem with keys being stuck down then I think Send is the most likely problem. A similar problem can occur with BlockInput apparently. The solution is generally quite simple. If there is a key like Shfit or Alt held down at the start of the Send sequence, but that key is released by the time the Send sequence finishes then the key will get 'stuck' down. So you could replace Send everywhere in your script with _SendEx

Func _SendEx($ss)
    Local $iT = TimerInit()
    
    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
        If TimerDiff($iT) > 1000 Then
            MsgBox(262144, "Warning", "Shift, Ctrl and Alt Keys need to be released to proceed!")
        EndIf
    WEnd
    Send($ss)
    
EndFunc  ;==>_SendEx
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.
Link to comment
Share on other sites

If you use Send in a script and you have a problem with keys being stuck down then I think Send is the most likely problem. A similar problem can occur with BlockInput apparently. The solution is generally quite simple. If there is a key like Shfit or Alt held down at the start of the Send sequence, but that key is released by the time the Send sequence finishes then the key will get 'stuck' down. So you could replace Send everywhere in your script with _SendEx

Func _SendEx($ss)
    Local $iT = TimerInit()
    
    While _IsPressed("10") Or _IsPressed("11") Or _IsPressed("12")
        If TimerDiff($iT) > 1000 Then
            MsgBox(262144, "Warning", "Shift, Ctrl and Alt Keys need to be released to proceed!")
        EndIf
    WEnd
    Send($ss)
    
EndFunc ;==>_SendEx

Thanks very much for explaining that so clearly. I certainly wouldn't have worked it out for myself! Used a slightly-modified version of your function and ... problem solved!

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...