作者共發了3篇帖子。 內容轉換:不轉換▼
 
點擊 回復
567 2
【VC6示例代码】关闭右下角广告弹窗
一派護法 十九級
1樓 發表于:2013-6-12 11:36

SetCursorPos(1903,901); //关闭按钮的位置
 mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
 mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0); //鼠标按下后必须弹起!!切记!

一派護法 十九級
2樓 發表于:2013-6-12 11:38

void CADSInterceptorDlg::CheckADs()
{
 //一次只允许运行一个实例
 if (running)
  return;
 running=true;
 int screen_width=GetSystemMetrics(SM_CXSCREEN); //屏幕分辨率
 int screen_height=GetSystemMetrics(SM_CYSCREEN);
 HDC hDC=::GetDC(0); //得到当前屏幕DC
 CBitmap bmp;
 bmp.LoadBitmap(IDB_BITMAP1);
 CWindowDC dcDesktop(NULL);
 CDC dcTmp;
 dcTmp.CreateCompatibleDC(&dcDesktop);
 dcTmp.SelectObject(&bmp);
 
 const int range=10;
 bool flag2=false;
 for (int add_x=-range;add_x<range;add_x++)
 {
  for (int add_y=-range;add_y<range;add_y++)
  {
   CPoint start_pos(242+add_x,190+add_y);
   start_pos.x=screen_width-start_pos.x+2;
   start_pos.y=screen_height-start_pos.y+2;
   
   COLORREF color=::GetPixel(hDC,start_pos.x,start_pos.y);
   COLORREF bmp_color=dcTmp.GetPixel(0,0);
   if (bmp_color==color)
   {
    //AfxMessageBox("检测到了!");
    //再检查几个像素看是否符合
    CPoint checking_pos;
    bool flag=true;
    for (int i=0;i<50;i++)
    {
     checking_pos.x=start_pos.x+i;
     for (int j=0;j<6;j++)
     {
      checking_pos.y=start_pos.y+j;
      bmp_color=dcTmp.GetPixel(i,j);
      color=::GetPixel(hDC,checking_pos.x,checking_pos.y);
      if (color!=bmp_color)
      {
       flag=false;
       break;
      }
     }
    }
    GetCursorPos(&checking_pos);
    if (flag)
    {
     //AfxMessageBox("检测到了!");
     for (int add_x_2=-range;add_x_2<range;add_x_2++)
     {
      for (int add_y_2=-range;add_y_2<range;add_y_2++)
      {
       SetCursorPos(screen_width-15+add_x+add_x_2,screen_height-175+add_y+add_y_2);
       //Sleep(100);
       mouse_event(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0);
       mouse_event(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0);//鼠标按下后必须弹起!!切记!
      }
     }
    }
    flag2=true;
    SetCursorPos(checking_pos.x,checking_pos.y);
   }
  }
 }
 if (flag2)
  Record(); //可以用该函数记录弹窗的时间到文件
 running=false;
 /*CString str;
 str.Format("%d,%d,%d",GetRValue(color),GetGValue(color),GetBValue(color));
 AfxMessageBox(str);*/
}

这段代码主要是根据IDB_BITMAP1中保存的弹窗窗口部分截图,监控右下角是否有与IDB_BITMAP1中完全匹配的广告窗口。如果在range范围类发现了,立即移动鼠标关闭该广告窗口并还原鼠标位置。

一派護法 十九級
3樓 發表于:2013-6-12 11:39
使用该段代码可以有效的监控并自动关闭右下角弹窗。

回復帖子

內容:
用戶名: 您目前是匿名發表
驗證碼:
(快捷鍵:Ctrl+Enter)
 

本帖信息

點擊數:567 回複數:2
評論數: ?
作者:巨大八爪鱼
最後回復:巨大八爪鱼
最後回復時間:2013-6-12 11:39
 
©2010-2024 Arslanbar Ver2.0
除非另有聲明,本站採用創用CC姓名標示-相同方式分享 3.0 Unported許可協議進行許可。