{*******************************************************} { } { ThdMsgAutoClose } { } { Copyright (C) 2023 kku } { } {*******************************************************} unit ThdMsgAutoClose; interface uses Tocsg.Thread, System.SysUtils, System.Classes, Winapi.Windows, Winapi.Messages; type TThdMsgAutoClose = class(TTgThread) protected procedure Execute; override; end; implementation uses Tocsg.WndUtil, Tocsg.Safe; procedure TThdMsgAutoClose.Execute; var h, hNext: HWND; sCap: String; i: Integer; begin while not Terminated and not GetWorkStop do begin h := GetForegroundWindow; if (h <> 0) and (GetWndClassName(h) = '#32770') then begin sCap := UpperCase(GetWindowCaption(h)); // if Pos('열기', sCap) > 0 then if Pos('잘못된 이미지', sCap) > 0 then PostMessage(h, WM_CLOSE, 0, 0); end else begin h := FindWindowEx(0, 0, '#32770', nil); if h <> 0 then begin while h <> 0 do begin hNext := GetWindow(h, GW_HWNDNEXT); if GetWndClassName(h) = '#32770' then begin sCap := UpperCase(GetWindowCaption(h)); if sCap <> '' then begin // if Pos('열기', sCap) > 0 then if Pos('잘못된 이미지', sCap) > 0 then PostMessage(h, WM_CLOSE, 0, 0); end; end; h := hNext; end; end; end; Sleep(100); end; end; end.