Hi.
The title explains it all. But I will make myself understood. If someone has created a big script out of little scripts, and they did it when they were a newbie, if in any of their scripts a key is held down (sometimes triggered by pressing two keys at the same time), what causes the computer becomes erratic, in such a way that the only way to resolve the situation is to restart the computer... is there any routine or way to know that a key has been pressed and which key it is, by reversing its pressing? Going through all the scripts becomes infeasible and tedious (but I know I'll have to do it sometime).
Detect if a key has been left pressed inside a script
Re: Detect if a key has been left pressed inside a script
Hallo,
try:
And try this. All currently pressed keys and buttons are displayed. A mouse wheel rotation saves it to the clipboard.
try:
Code: Select all
*q::Release_Keys()
Release_Keys()
{ ;release all pressed keys
Loop, 0xFF
IF GetKeyState(Key:=Format("VK{:X}",A_Index))
SendInput, {%Key% up}
}
Code: Select all
; Send, {q Down}{w Down}
SetTimer, KeyCombination, 50,% ClipBoard := ""
KeyCombination:
IF A_TimeIdlePhysical > 100
Return
KeyCombination := KeyCombination()
ToolTip,% KeyCombination?KeyCombination:"ClipBoard:`n" ClipBoard
Return
*WheelUp::
*WheelDown::ClipBoard := KeyCombination
KeyCombination(ExcludeKeys:="")
{ ;All pressed keys and buttons will be listed
ExcludeKeys .= "{Shift}{Control}{Alt}{WheelUp}{WheelDown}"
Loop, 0xFF
{
IF !GetKeyState(Key:=Format("VK{:02X}",0x100-A_Index))
Continue
If !InStr(ExcludeKeys,Key:="{" GetKeyName(Key) "}")
KeyCombination .= RegexReplace(Key,"Numpad(\D+)","$1")
}
Return, KeyCombination
}
Re: Detect if a key has been left pressed inside a script
Thank you very much @Rohwedder.
I have tried the second one and it works perfectly. I will have the first one as an emergency kit for when it happens again.
I have tried the second one and it works perfectly. I will have the first one as an emergency kit for when it happens again.