Skip to content

Instantly share code, notes, and snippets.

@jrw254
Created April 16, 2021 03:46
Show Gist options
  • Select an option

  • Save jrw254/aa99fb671394ee27f59bd20d951722d8 to your computer and use it in GitHub Desktop.

Select an option

Save jrw254/aa99fb671394ee27f59bd20d951722d8 to your computer and use it in GitHub Desktop.
#SingleInstance Force
#Persistent
#InstallKeybdHook
/*
GetKeyStateTest.ahk
v 1.0
April 15th 2021
By: JRW254/Sabedth
Description:
Just a simple stuck key detector.
For common modifiers.
Splashtext is depricated but uses less lines.
Building a GUI is recommended in place of Splashtext.
*/
SetTimer, KDown, 10 ; Detects key's
SetTimer, PSKey, 20 ; Erases Detect keys
; KeyState variables
STTAlt := "Alt is Down"
STTShift := "Shift is Down"
STTControl := "Control is Down"
STTWinKey := "Left WinKey is Down"
; Counter variables
AltCount := 0
ShiftCount := 0
CtrlCount := 0
WinCount := 0
; KDown label
KDown:
if GetKeyState("Alt")
{
SplashTextOn, , , % STTAlt
AltCount++
WinMove, % STTAlt,, 910, 739
}
if GetKeyState("Shift")
{
SplashTextOn, , , % STTShift
ShiftCount++
WinMove, % STTShift,, 910, 739
}
if GetKeyState("Ctrl")
{
SplashTextOn, , , % STTControl
CtrlCount++
WinMove, % STTControl,, 910, 739
}
if GetKeyState("LWin")
{
SplashTextOn, , , % STTWinKey
WinCount++
WinMove, % STTWinKey,, 910, 739
}
; PSKey label
PSKey:
SplashTextOff,,, % STTAlt
SplashTextOff,,, % STTShift
SplashTextOff,,, % STTControl
SplashTextOff,,, % STTWinKey
; MsgBox that Display's number count of the key's being counted
PrintScreen:: MsgBox, Alt: %AltCount% `nShift: %ShiftCount% `nControl: %CtrlCount% `nWindow: %WinCount%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment