DEV Community

Query Filter
Query Filter

Posted on

docker-159

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

; --- CONFIGURATION ---
TargetLibrary := "jaxb-api" ; The library text snippet you want to find
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 searching.

; 1. Initialize and display a wide feedback progress window
Progress, b w600 H110 zh0 fs10 c00,, Fetching UI control data..., AHK Dependencies Finder
Progress, 0

; 2. GRAB THE ENTIRE LIST DIRECTLY FROM THE INTELLIJ MEMORY WINDOW BUFFER
; This bypasses Ctrl+C entirely to prevent blank clipboard errors.
ControlGet, FullDependencyList, List,, SvList1, Project Structure
if (ErrorLevel or FullDependencyList = "") {
    ; Fallback to standard focused control if class name differs in your IDE version
    ControlGetFocus, ActiveControl, Project Structure
    ControlGet, FullDependencyList, List,, %ActiveControl%, Project Structure
}

; 3. If memory reading fails completely, warn immediately
if (FullDependencyList = "") {
    Progress, Off
    MsgBox, 16, Error, Could not read list memory directly. Make sure the Project Structure window is active.
    ExitApp
}

; 4. Parse the extracted memory string line by line
Loop, parse, FullDependencyList, `n, `r
{
    LibraryIndex++

    ; Cap the search row limit
    if (LibraryIndex > MaxRows)
        break

    CurrentRowText := Trim(A_LoopField)

    ; Format text for the display box preview
    DisplayText := CurrentRowText
    if (StrLen(DisplayText) > 75)
        DisplayText := SubStr(DisplayText, 1, 72) . "..."

    ; Visually show the index number alongside the EXACT text read from that row
    ProgressPercent := (LibraryIndex / MaxRows) * 100
    Progress, %ProgressPercent%, Row: %LibraryIndex% | Checked Text: "%DisplayText%", Searching for "%TargetLibrary%"...

    ; Evaluate match condition
    if (InStr(CurrentRowText, TargetLibrary)) {
        FoundMatch := true
        break
    }

    ; Move the physical visual cursor down in sync with the loop for tracking
    Send, {Down}
    Sleep, 15 ; Minimal delay just for visual tracking sync
}

; 5. Close the progress feedback window
Progress, Off

; 6. Output the final index calculation
if (FoundMatch) {
    MsgBox, 64, Success, Match Found!`n`nIndex Row: %LibraryIndex%`nFull Line Text: %CurrentRowText%
} else {
    MsgBox, 16, Failed, Could not locate "%TargetLibrary%" within the evaluated %LibraryIndex% entries.
}

ExitApp
Enter fullscreen mode Exit fullscreen mode

Top comments (0)