DEV Community

Query Filter
Query Filter

Posted on

key2

; ===== CONFIG =====
libraryName := "my-bad-library.jar"
windowTitle := "Project Structure"

SetTitleMatchMode, 2
CoordMode, Mouse, Screen

; ===== ACTIVATE WINDOW =====
IfWinNotExist, %windowTitle%
{
    MsgBox, Project Structure window not found
    ExitApp
}

WinActivate, %windowTitle%
WinWaitActive, %windowTitle%
Sleep, 300

; ===== AUTO-FOCUS MODULE TREE =====
maxTabs := 15
prevCtrl := ""
focused := false

Loop, %maxTabs%
{
    ControlGetFocus, curCtrl, %windowTitle%
    if (curCtrl = prevCtrl && curCtrl != "")
    {
        focused := true
        break
    }

    prevCtrl := curCtrl
    Send, {Tab}
    Sleep, 120
}

if (!focused)
{
    MsgBox, Failed to focus Modules tree automatically
    ExitApp
}

; ===== CLEAR ANY PREVIOUS SEARCH =====
Send, {Esc}
Sleep, 100

; ===== TYPE-TO-SEARCH =====
SendInput, %libraryName%
Sleep, 300

; ===== CONFIRM SELECTION =====
Send, {Enter}
Sleep, 200

; ===== RETURN POSITION =====
MouseGetPos, x, y
MsgBox, Library selected at:`nX=%x%`nY=%y%

return

Enter fullscreen mode Exit fullscreen mode

Top comments (0)