DEV Community

Query Filter
Query Filter

Posted on

key15

#SingleInstance Force
#NoEnv
SetTitleMatchMode, 2
CoordMode, Mouse, Screen
CoordMode, ToolTip, Screen

moveCount := 0
active := true

UpdateToolTip() {
    global moveCount, active
    status := active ? "ACTIVE" : "INACTIVE"
    ToolTip, %status% - Clicks: %moveCount%, 20, 20
}

UpdateToolTip()

; ===== MOUSE CLICK DETECTION FOR ARROW ICONS =====
#If WinActive("ahk_exe idea.exe") or WinActive("ahk_exe idea64.exe")

~LButton::  ; Detect left mouse clicks in IntelliJ
    if (!active)
        return

    ; Get mouse position and pixel color
    MouseGetPos, mouseX, mouseY
    PixelGetColor, pixelColor, %mouseX%, %mouseY%, RGB

    ; Get window info at click location
    MouseGetPos, , , windowID, controlClassNN

    ; Debug: Uncomment to see what you're clicking on
    ; ToolTip, Click at %mouseX%, %mouseY%`nColor: %pixelColor%`nControl: %controlClassNN%, mouseX+20, mouseY+20
    ; SetTimer, RemoveDebugTip, -2000

    ; Check if this is likely an arrow icon click
    ; Arrow icons are usually small (10-20px) and have specific colors
    ; You'll need to adjust these values based on your IntelliJ theme

    ; Common arrow icon colors (adjust based on your theme):
    ; - Gray arrows: ~0x808080
    ; - Blue arrows: ~0x0000FF  
    ; - Dark arrows: ~0x404040

    ; Check a small area around the click for arrow-like colors
    arrowDetected := false

    ; Sample 3x3 grid around the click point
    Loop, 3 {
        x := mouseX + (A_Index - 2) * 2  ; -2, 0, +2
        Loop, 3 {
            y := mouseY + (A_Index - 2) * 2  ; -2, 0, +2
            PixelGetColor, sampleColor, %x%, %y%, RGB

            ; Convert to decimal for easier comparison
            sampleColor := "0x" . SubStr(sampleColor, 3)

            ; Check for dark colors (likely arrow icons)
            if (sampleColor < 0x888888) {  ; Darker than medium gray
                arrowDetected := true
                break 2
            }
        }
    }

    if (arrowDetected) {
        ; Also check if we're in a tree/list control (where arrows usually are)
        if (InStr(controlClassNN, "TreeView") or InStr(controlClassNN, "SysTreeView32") 
            or InStr(controlClassNN, "SysListView32")) {

            moveCount++
            UpdateToolTip()
            SoundBeep, 800, 50  ; Optional audible feedback
        }
    }
return

; Alternative: Hotkey to manually add to count when you click arrows
#If (WinActive("ahk_exe idea.exe") or WinActive("ahk_exe idea64.exe")) && GetKeyState("Ctrl", "P")
LButton::  ; Ctrl+Click to manually count arrow clicks
    moveCount++
    UpdateToolTip()
    SoundBeep, 1000, 50
    Click  ; Perform the actual click
return

#If  ; End context

RemoveDebugTip:
    ToolTip
return

; ===== CONTROL HOTKEYS =====
Esc::
    active := !active
    UpdateToolTip()

    if (!active) {
        SetTimer, HideInactiveToolTip, -1500
    }
return

HideInactiveToolTip:
    if (!active) {
        ToolTip
    }
return

^r::  ; Reset counter
    moveCount := 0
    UpdateToolTip()
    SoundBeep, 500, 200
return

F1::  ; Debug: Show click info
    MouseGetPos, mouseX, mouseY
    PixelGetColor, pixelColor, %mouseX%, %mouseY%, RGB
    MouseGetPos, , , windowID, controlClassNN
    WinGetTitle, windowTitle, ahk_id %windowID%

    MsgBox, Click Debug:`nPos: %mouseX%, %mouseY%`nColor: %pixelColor%`nControl: %controlClassNN%`nWindow: %windowTitle%
return

F2::  ; Add to count manually
    moveCount++
    UpdateToolTip()
    SoundBeep, 600, 100
return
Enter fullscreen mode Exit fullscreen mode

Top comments (0)