Thanks for that, in the end I used a modified version of the Neftali code , I included it below if someone else has problems in the future,
FindWindow(PChar('notepad'), nil);
always returned 0, therefore, looking for the reason why I found this function that will find hwnd, and it worked.
function FindWindowByTitle(WindowTitle: string): Hwnd;
var
NextHandle: Hwnd;
NextTitle: array[0..260] of char;
begin
NextHandle := GetWindow(Application.Handle, GW_HWNDFIRST);
while NextHandle > 0 do
begin
GetWindowText(NextHandle, NextTitle, 255);
if Pos(WindowTitle, StrPas(NextTitle)) <> 0 then
begin
Result := NextHandle;
Exit;
end
else
NextHandle := GetWindow(NextHandle, GW_HWNDNEXT);
end;
Result := 0;
end;
procedure hideExWindow()
var Indicador:Hwnd;
begin
Indicador := FindWindowByTitle('MyApp');
if (Indicador <> 0) then
begin
ShowWindow(Indicador,SW_HIDE);
end;
end;
source
share