function StrLeft(const mStr: string; mDelimiter: string): string;
begin
Result := Copy(mStr, 1, Pos(mDelimiter, mStr) - 1);
end; { StrLeft }
function StrRight(const mStr: string; mDelimiter: string): string;
begin
if Pos(mDelimiter, mStr) > 0 then
Result := Copy(mStr, Pos(mDelimiter, mStr) + Length(mDelimiter), MaxInt)
else Result := '';
end; { StrRight }
procedure TForm1.Timer1Timer(Sender: TObject);
var
vHandle: THandle;
vBuffer: array[0..255] of Char;
I: Integer;
begin
vHandle :=FindWindow('TMessageForm', nil);
TTimer(Sender).Enabled := vHandle <> 0;
if vHandle = 0 then Exit;
GetWindowText(vHandle, vBuffer, 256);
I := StrToIntDef(StrRight(vBuffer, ','), 11) - 1;
if I < 0 then SendMessage(vHandle, WM_SYSCOMMAND, SC_CLOSE, 0);