procedure TForm1.Timer1Timer(Sender: TObject);
var
  MainHD,WorkAHD,ViewHD: THandle;
  y_workA,y_view: LongInt;
  rect1,rect2: TRect;
begin
//kill AD
  MainHD:=FindWindowEX(0,0,'IEFrame',nil);
  if MainHD<>0 then
  begin
   WorkAHD:=FindWindowEx(MainHD,0,'WorkerA',nil);
   if WorkAHD<>0 then
   begin
    GetWindowRect(WorkAHD,rect1);
    y_workA:=rect1.Top;
    ViewHD:=FindWindowEX(MainHD,0,'Shell DocObject View',nil);
    if ViewHD<>0 then
    begin
      GetWindowRect(ViewHD,rect2);
      y_view:=rect2.Top;
      Form1.Caption:=IntToStr(y_workA)+'---'+IntToStr(y_view);
      if y_view - y_workA <5 then
        PostMessage(MainHD,WM_CLOSE,0,0);
    end;
    end;
   end;
end;
这里面哪里出错了? 谢谢指点

解决方案 »

  1.   

    IEFrame WorkerA 'Shell DocObject View'都是么?
    y_view - y_workA <5 代表什么?
      

  2.   

    tofj218 是不是timer太费资源了
    toxfreedom 广告窗口的WorkerA类和Shell DocObject View类的rect.top的值是相同的;
    正常IE窗口的WorkerA类和Shell DocObject View类的rect.top的值是不相同的;
      

  3.   

    要指定关键字,比如:ad、ad-、ad?之类的~~~~~~~~  
    你那样可能把正常页面搞掉了~~~~~~~~~~  这种关键字要自己收集,不同网站会有不同的格式!
      

  4.   

    MainHD:=FindWindowEX(0,0,'IEFrame',nil);
    是这里不对把,我看过一篇文章,也是讲这个问题的,好象有点地方有点小问题
      

  5.   

    procedure TForm1.Timer1Timer(Sender: TObject); var mainHD,WorkAHD,ViewHD:THandle; y_workA,y_view:integer; rect1,rect2:TRect; begin // Kill AD. mainHD:=FindWIndowEx(0,0,'CabinetWClass',nil); if Mainhd<>0 then begin WorkAHD:=FindWindowEx(Mainhd,0,'WorkerA',nil); GetwindowRect(WorkAHD,rect1); y_workA:=rect1.top; ViewHD:=FindWindowEx(mainHD,0,'Shell DocObject View',nil); if viewHD<>0 then ////注1: begin GetwindowRect(ViewHD,rect2); y_view:=rect2.top; if y_View-y_WorkA<5 then PostMessage(Mainhd,WM_CLOSE,0,0); end; end; end; 给分吧~:)
      

  6.   

    sorry~~~我实验了,好象不可以,因为上面的代码我直接从帖子上面copy的
    我改改,实验一下
      

  7.   

    我有MYIE的代码,它可以禁止弹出窗口不过是VC的
      

  8.   

    我用spy++看了,在xp下面 IEFrame下面是WORKERW,不存在WORKERA
    并且。(你我可能看过同一篇文章),上面那些查找依据是不存在的,奇怪
      

  9.   

    我现在在2000server里面也是实现不了
      

  10.   

    跟踪半天,终于是窗口类的错误。希望需要的人可以找到!procedure TForm1.Timer1Timer(Sender: TObject);
    var
      MainHD,WorkAHD,ViewHD: THandle;
      y_workA,y_view: LongInt;
      rect1,rect2: TRect;
    begin
      MainHD:=FindWindowEX(0,0,'IEFrame',nil);
      if MainHD<>0 then
      begin
        WorkAHD:=FindWindowEx(MainHD,0,'WorkerW',nil);
        if WorkAHD<>0 then
        begin
          GetWindowRect(WorkAHD,rect1);
          y_workA:=rect1.Top;
          ViewHD:=FindWindowEX(MainHD,0,'Shell DocObject View',nil);
          if ViewHD<>0 then
          begin
            GetWindowRect(ViewHD,rect2);
            y_view:=rect2.Top;
            Form1.Caption:=IntToStr(y_workA)+'---'+IntToStr(y_view);
            if y_view - y_workA <5 then
              PostMessage(MainHD,WM_CLOSE,0,0);
          end;
        end;
       end;
    end;