目前共有3篇帖子。 字体大小:较小 - 100% (默认)▼  内容转换:港澳繁體▼
 
点击 回复
648 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)
 

本帖信息

点击数:648 回复数:2
评论数: ?
作者:巨大八爪鱼
最后回复:巨大八爪鱼
最后回复时间:2013-6-12 11:39
 
©2010-2025 Purasbar Ver2.0
除非另有声明,本站采用知识共享署名-相同方式共享 3.0 Unported许可协议进行许可。