目前共有3篇帖子。 字體大小:較小 - 100% (默認)▼  內容轉換:台灣正體▼
 
點擊 回復
649 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)
 

本帖信息

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