DEV Community

Query Filter
Query Filter

Posted on

key9

#SingleInstance Force
SetTitleMatchMode, 2  ; partial match

moveCount := 0
active := true

UpdateToolTip() {
    global moveCount, active
    if (active) {
        ToolTip, Move counter ACTIVE`nMoves: %moveCount%, 20, 20
    } else {
        ToolTip, Move counter INACTIVE`nMoves: %moveCount%, 20, 20
    }
}

UpdateToolTip()  ; Initial tooltip

#IfWinActive, ideAutomation - FileExplorer  ; only active in this window

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

#IfWinActive  ; end context

; Toggle with Esc (global)
Esc::
    active := !active  ; Toggle instead of just turning off
    UpdateToolTip()

    ; If turning off, wait a moment then hide tooltip
    if (!active) {
        Sleep, 1000
        if (!active) {  ; Check again in case it was toggled back on
            ToolTip
        }
    }
return

; Optional: Add a reset counter hotkey (Ctrl+R)
^r::  ; Ctrl+R to reset
    moveCount := 0
    UpdateToolTip()
    SoundBeep, 500, 200  ; Audible feedback
return

; Optional: Show current count (Ctrl+Alt+S)
^!s::  ; Ctrl+Alt+S to show status
    MsgBox, Move counter is %active% active.`nTotal moves: %moveCount%
return
Enter fullscreen mode Exit fullscreen mode

Top comments (0)