在Delphi中新建一個(gè)PRoject1,在Form1上添加一個(gè)Timer,設(shè)置Interval為100ms,然后編寫(xiě)下面的代碼即可:
procedure TForm1.Timer1Timer(Sender: TObject);
var
  handle,hchild1,hchild2:THandle;
  point:TPoint;
  temp:array[0..255] of char;
begin
 ://取得當(dāng)前鼠標(biāo)的位置
  GetCursorPos(point);
 //取得當(dāng)前鼠標(biāo)所在窗體的句柄
 handle:=WindowFromPoint(point);
  GetClassName(handle,temp,256);
  //#32770是對(duì)話(huà)框的類(lèi)名,QQ窗體的類(lèi)名就是#32770
if temp='#32770' then
begin
  //為了確保是QQ登陸窗體,再檢查有沒(méi)有“登陸”和“注冊(cè)向?qū)А眱蓚€(gè)按扭
    hchild1:=FindWindowEx(handle,0,'Button','登錄');
    hchild2:=FindWindowEx(handle,0,'Button','注冊(cè)向?qū)?);
    if (hchild1<>0) and (hchild2<>0) then
       SendMessage(handle,WM_CLOSE,0,0);
  end;
end;
呵呵! 很簡(jiǎn)單吧!要注意的是,QQ窗體的“QQ用戶(hù)登陸”這個(gè)標(biāo)題是畫(huà)上去的,不能簡(jiǎn)單的用FindWindow(窗體句柄,“QQ用戶(hù)登陸”)來(lái)判斷。
新聞熱點(diǎn)
疑難解答
圖片精選
網(wǎng)友關(guān)注