DEV Community

Query Filter
Query Filter

Posted on

key10

Up::
#SingleInstance Force
SetTitleMatchMode, 2  ; partial match
CoordMode, ToolTip, Screen  ; Make tooltip appear at screen coordinates

moveCount := 0
active := true

UpdateToolTip() {
    global moveCount, active
    status := active ? "ACTIVE" : "INACTIVE"
    ToolTip, Move counter %status%`nMoves: %moveCount%, 20, 20
}

UpdateToolTip()  ; Initial tooltip

#If WinActive("ahk_exe idea.exe") or WinActive("ahk_exe idea64.exe")
; Hotkeys only work when IntelliJ IDEA is active

Up::
    if (!active)
        return

    ; Anti-repeat: Ignore if same key pressed within 120ms
    if (A_PriorHotkey = "Up" && A_TimeSincePriorHotkey < 120)
        return

    moveCount++
    UpdateToolTip()
    SendInput, {Up}
return

Down::
    if (!active)
        return

    ; Anti-repeat: Ignore if same key pressed within 120ms
    if (A_PriorHotkey = "Down" && A_TimeSincePriorHotkey < 120)
        return

    moveCount--
    UpdateToolTip()
    SendInput, {Down}
return

#If  ; End context-sensitive hotkeys

; Toggle active state with Esc (global hotkey)
Esc::
    active := !active
    UpdateToolTip()

    ; If turning inactive, hide tooltip after 1.5 seconds
    if (!active) {
        Sleep, 1500
        if (!active) {  ; Check again in case it was toggled back on
            ToolTip
        }
    }
return

; Reset counter to 0 (Ctrl+R)
^r::
    moveCount := 0
    UpdateToolTip()
    SoundBeep, 500, 200  ; Audible feedback
return

; Show status (Ctrl+Alt+S)
^!s::
    statusText := active ? "ACTIVE" : "INACTIVE"
    MsgBox, Move Counter Status:`nState: %statusText%`nTotal moves: %moveCount%
return
Enter fullscreen mode Exit fullscreen mode

Top comments (0)