请教显示隐藏所有同名窗口ShowWindow
游戏多开,有很多同名窗口,但我这样的代码只能隐藏或显示第一个窗口,如何实现一次性全部隐藏或显示所有同名窗口请高手指点下!
procedure TForm1.Button13Click(Sender: TObject);
var
h1:hwnd;
begin
h1:=FindWindow('TFrmMain','legend of mir2');
if button13.caption='隐藏游戏' then
begin
ShowWindow(h1,0);
Button13.caption:='显示游戏';
end
else
begin
ShowWindow(h1,5);
Button13.caption:='隐藏游戏';
end;
end; FINDWINDOW只能获取一个.
你遍历下所有窗口.是游戏的就都隐藏. function EnumWindowProc(AWnd: HWND; AlParam: LPARAM):Boolean;stdcall;//遍历
var
strCaption,strClassName: pChar;
p:Dword;
begin
GetMem(strCaption, 255);
GetMem(strClassName, 255);
GetWindowText(AWnd, strCaption,255);//窗口
GetClassName(AWnd, strClassName, 255);//类
GetWindowThreadProcessId(awnd,@P);//PID
if (StrPas(strClassname)='UniqueGameUniqueWWindowsViewportWindow') then
begin
if p=GetCurrentProcessId then
begin
//form1.mmo1.Lines.Add(IntToHex(AWnd,8)+'|'+inttostr(p)+'|'+inttostr(GetCurrentProcessId));
msws:=awnd;
end;
end;
Result := True;
end;
页:
[1]