DEV Community

Query Filter
Query Filter

Posted on

intel7

; ==============================================================================
; 1. INITIALIZATION (Standard User Mode)
; ==============================================================================
#NoEnv
#SingleInstance Force
SetTitleMatchMode, 2

; Use 'Screen' coordinates to bridge the gap between different terminals
CoordMode, ToolTip, Screen
CoordMode, Mouse, Screen
CoordMode, Gui, Screen

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

; Find the unique ID (Handle) of IntelliJ and store it globally
WinGet, intellij_id, ID, %TargetProcess%

if (intellij_id)
{
    ; Jump to the IntelliJ Terminal
    WinActivate, ahk_id %intellij_id%
    WinWaitActive, ahk_id %intellij_id%, , 3

    ; Give Windows a moment to settle the desktop switch
    Sleep, 500 

    ; Get coordinates to verify position
    WinGetPos, iX, iY, iW, iH, ahk_id %intellij_id%

    ; Calculate Center for the Visual Ping
    CX := iX + (iW / 2)
    CY := iY + (iH / 2)

    ; Visual Ping (Red Dot)
    Gui, RedDot: +AlwaysOnTop -Caption +ToolWindow +LastFound
    Gui, RedDot: Color, Red
    Gui, RedDot: Show, % "x" (CX - 10) " y" (CY - 10) " w20 h20 NoActivate"

    ToolTip, `n`t TARGET ACQUIRED: INTELLIJ `n`t, %CX%, % (CY - 80)

    Sleep, 1000
    Gui, RedDot: Destroy
    ToolTip
}
else
{
    MsgBox, 16, Startup Error, IntelliJ (idea64.exe) was not found.`nPlease open IntelliJ and try again.
    ExitApp
}

; ==============================================================================
; 3. YOUR CODE STARTS HERE
; ==============================================================================

; EXAMPLE USAGE:
; SmartAlert("Success", "The script is running on the correct terminal!")

Return ; End of Auto-Execute section

; ==============================================================================
; 4. SMART ALERT FUNCTION (Replacement for MsgBox)
; ==============================================================================
SmartAlert(Title, Message) {
    global intellij_id ; Uses the ID captured in the header

    ; Refresh coordinates in case the window was moved
    WinGetPos, iX, iY, iW, iH, ahk_id %intellij_id%

    ; Center math
    PosX := iX + (iW / 2) - 150
    PosY := iY + (iH / 2) - 75

    Gui, Alert: +AlwaysOnTop -MinimizeBox +HwndAlertHwnd
    Gui, Alert: Color, White
    Gui, Alert: Font, s12 w700, Segoe UI
    Gui, Alert: Add, Text, Center w300, %Message%
    Gui, Alert: Add, Button, gCloseAlert Default Center w80 x115 y+20, OK

    ; Show specifically at the IntelliJ coordinates
    Gui, Alert: Show, x%PosX% y%PosY%, %Title%

    ; Wait for user to click OK before script continues
    WinWaitClose, ahk_id %AlertHwnd%
    return

    CloseAlert:
    Gui, Alert: Destroy
    return
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)