設置 | 登錄 | 註冊

作者共發了3篇帖子。

【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
使用該段代碼可以有效的監控並自動關閉右下角彈窗。

內容轉換:

回覆帖子
內容:
用戶名: 您目前是匿名發表。
驗證碼:
看不清?換一張
©2010-2025 Purasbar Ver3.0 [手機版] [桌面版]
除非另有聲明,本站採用知識共享署名-相同方式共享 3.0 Unported許可協議進行許可。