DEV Community

Query Filter
Query Filter

Posted on

intel3

; ==============================================================================
; STEP 1: INITIALIZATION & ADMIN PRIVILEGES
; ==============================================================================
#NoEnv
#SingleInstance Force
SetWorkingDir %A_ScriptDir%
SetTitleMatchMode, 2

; Force script to run as Admin (Required to interact with IntelliJ if it's elevated)
if not A_IsAdmin {
    Run *RunAs "%A_ScriptFullPath%",, UseErrorLevel
    ExitApp
}

; Set coordinate modes to "Window" so everything anchors to IntelliJ
CoordMode, ToolTip, Window
CoordMode, Mouse, Window
CoordMode, Gui, Window

; ==============================================================================
; STEP 2: THE TELEPORTATION HEADER
; ==============================================================================
TargetProcess := "ahk_exe idea64.exe"

IfWinExist, %TargetProcess%
{
    ; Capture the unique handle of the IntelliJ window
    WinGet, intellij_id, ID, %TargetProcess%

    ; Jump to the IntelliJ Terminal/Desktop
    WinActivate, ahk_id %intellij_id%
    WinWaitActive, ahk_id %intellij_id%, , 2

    if ErrorLevel {
        MsgBox, 16, Teleport Error, Could not focus IntelliJ in time.
        ExitApp
    }

    ; Small buffer for Java UI to stabilize after terminal switch
    Sleep, 200 

    ; ==========================================================================
    ; STEP 3: VISUAL CONFIRMATION (RED DOT & TOOLTIP)
    ; ==========================================================================
    ; Calculate Center of IntelliJ Window
    WinGetPos, , , w, h, ahk_id %intellij_id%
    CenterX := w / 2
    CenterY := h / 2

    ; Create Red Dot (Circle)
    Gui, RedDot: +AlwaysOnTop -Caption +ToolWindow +LastFound
    Gui, RedDot: Color, Red
    WinSet, Region, 0-0 20-20 R20-20 ; Makes it a 20x20 circle

    ; Show Dot and ToolTip (NoActivate ensures we don't steal keyboard focus)
    Gui, RedDot: Show, % "x" (CenterX - 10) " y" (CenterY - 10) " w20 h20 NoActivate"
    ToolTip, `n`t TARGET ACQUIRED: INTELLIJ `n`t, %CenterX%, % (CenterY - 80)

    ; Flash the dot 2 times
    Sleep, 400
    Gui, RedDot: Hide
    Sleep, 200
    Gui, RedDot: Show, NoActivate

    ; Clean up visuals
    Sleep, 800
    Gui, RedDot: Destroy
    ToolTip

    ; ==========================================================================
    ; STEP 4: PREPARE DIALOGS (Ensures MsgBox follows to this terminal)
    ; ==========================================================================
    Gui, +OwnDialogs ; All future MsgBoxes/Dialogs will be pinned to IntelliJ
}
else
{
    MsgBox, 16, Startup Error, IntelliJ (idea64.exe) is not running!
    ExitApp
}

; ==============================================================================
; YOUR CODE STARTS HERE
; ==============================================================================
; Example:
; MsgBox, 64, Success, You are now automating IntelliJ on this terminal!
Enter fullscreen mode Exit fullscreen mode

Top comments (0)