DALLASCAO.COM

Site of Cao Shouguang, English to Chinese translator

Autohotkey: Disable the close button [X] of a GUI window

DISABLE() ;By RealityRipple at http://www.xtremevbtalk.com/archive/index.php/t-258725.html
{
  WinGet, id, ID, A
  menu:=DllCall("user32\GetSystemMenu","UInt",id,"UInt",0)
  DllCall("user32\DeleteMenu","UInt",menu,"UInt",0xF060,"UInt",0x0)
  WinGetPos,x,y,w,h,ahk_id %id%
  WinMove,ahk_id %id%,,%x%,%y%,%w%,% h-1
  WinMove,ahk_id %id%,,%x%,%y%,%w%,% h+1
}

Then insert DISABLE() after GUI, show command to call the function.

Leave a Comment