DEV Community

Query Filter
Query Filter

Posted on

docker-158

; Ensure the script runs with optimal clipboard handling speeds
#NoEnv
SetBatchLines, -1
SendMode Input

; --- CONFIGURATION ---
TargetLibrary := "jaxb-api" ; Change this to your target or partial name
LibraryIndex := 0
MaxRows := 800              ; Capped at 800 entries max
FoundMatch := false

MsgBox, 64, AHK Finder, Please click inside your IntelliJ Dependencies list box, then press OK to begin counting.

; 1. Initialize and display a wider progress window to fit long library names
Progress, b w500 H110 zh0 fs10 c00,, Preparing search..., AHK Dependencies Finder
Progress, 0

; 2. Jump to the absolute top of the dependencies list
Send, {Home}
Sleep, 300 ; Give IntelliJ plenty of time to snap to the top row

; 3. Iterate down while keeping count
Loop, %MaxRows% {
    LibraryIndex++

    ; Clear the clipboard completely to prevent cross-contamination
    Clipboard := "" 

    ; Send Ctrl+C to copy the text of the currently highlighted row
    Send, ^c 
    ClipWait, 0.3 ; Increased wait window to 300ms for stability

    ; Clean up the clipboard text (remove formatting, hidden carriage returns, tabs)
    CurrentRowText := Trim(Clipboard)

    ; Abbreviate text if it's too long for the Progress window display
    DisplayText := CurrentRowText
    if (StrLen(DisplayText) > 65)
        DisplayText := SubStr(DisplayText, 1, 62) . "..."

    ; Update the visual progress window with the current row index and the raw text found
    ProgressPercent := (LibraryIndex / MaxRows) * 100
    Progress, %ProgressPercent%, Checking Row %LibraryIndex%: `n"%DisplayText%", Searching for "%TargetLibrary%"...

    ; Check if the row text contains your target library name (case-insensitive)
    if (InStr(CurrentRowText, TargetLibrary)) {
        FoundMatch := true
        break
    }

    ; Extra safety: If it completely failed to copy anything, pause an extra moment
    if (CurrentRowText = "") {
        Sleep, 50
    }

    ; Move down to the next library item in the list
    Send, {Down}
    Sleep, 80 ; Increased delay from 40ms to 80ms to prevent skipping rows
}

; 4. Close the progress feedback window
Progress, Off

; 5. Output the final calculation result
if (FoundMatch) {
    MsgBox, 64, Success, Found "%TargetLibrary%" at UI Index row: %LibraryIndex%`nFull Name: %CurrentRowText%
} else {
    MsgBox, 16, Failed, Could not locate "%TargetLibrary%" within the capped %MaxRows% entries.
}

ExitApp
Enter fullscreen mode Exit fullscreen mode

Top comments (0)