DEV Community

Query Filter
Query Filter

Posted on

intel8

SmartAlert(Title, Message) {
    global intellij_id ; Uses the ID captured in the header

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

    ; 2. Define the new WIDTH here
    BoxWidth := 500

    ; 3. Centering math (Calculates based on the new 500px width)
    PosX := iX + (iW / 2) - (BoxWidth / 2)
    PosY := iY + (iH / 2) - 75

    ; 4. Build the Wider GUI
    Gui, Alert: +AlwaysOnTop -MinimizeBox +HwndAlertHwnd
    Gui, Alert: Color, White
    Gui, Alert: Font, s12 w700, Segoe UI

    ; Width set to BoxWidth (500)
    Gui, Alert: Add, Text, Center w%BoxWidth%, %Message%

    ; Button centered: (500 / 2) - (80 / 2) = 210
    Gui, Alert: Add, Button, gCloseAlert Default Center w80 x210 y+20, OK

    ; Show specifically at the IntelliJ coordinates
    Gui, Alert: Show, x%PosX% y%PosY% w%BoxWidth%, %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)