• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

关闭QQ右下角弹窗小程序

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

关闭QQ右下角弹出的广告或新闻等。

程序没有界面,后台运行。

 

  1 #if defined(UNICODE) && !defined(_UNICODE)
  2     #define _UNICODE
  3 #elif defined(_UNICODE) && !defined(UNICODE)
  4     #define UNICODE
  5 #endif
  6 
  7 #include <tchar.h>
  8 #include <windows.h>
  9 
 10 #include <iostream>
 11 #include <stdio.h>
 12 #include <windows.h>
 13 #include <vector>
 14 #include <time.h>
 15 //#include <afxwin.h>
 16 using namespace std;
 17 
 18 
 19 
 20 /*  Declare Windows procedure  */
 21 LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
 22 
 23 /*  Make the class name into a global variable  */
 24 TCHAR szClassName[ ] = _T("CodeBlocksWindowsApp");
 25 
 26 
 27 char* tmp=new char[32];
 28 LPTSTR s=new char[100];
 29 
 30 char* gettime(){
 31     time_t t = time(0);
 32     strftime(tmp, 32, "%Y-%m-%d %H:%M:%S",localtime(&t));
 33     return tmp;
 34 }
 35 char* gettext(HWND hwnd){
 36     GetWindowText(hwnd,s,100);
 37     return s;
 38 }
 39 int print_window(HWND hwnd,long w,long h,FILE* f){
 40     printf("%d  (%ld,%ld)   %s   %s\n",(int)hwnd,w,h,gettime(),gettext(hwnd));
 41     fprintf(f,"%d  (%ld,%ld)   %s   %s\n",(int)hwnd,w,h,gettime(),gettext(hwnd));
 42     fflush(f);
 43     return 0;
 44 }
 45 int mmain(){
 46     FILE* f=fopen("main_log.txt","a");
 47     cout<<"Start Program."<<endl;
 48     fprintf(f,"\nStart Program.\n");
 49     fflush(f);
 50     HWND qhwnd=NULL;
 51     while(true){
 52         Sleep(333);
 53         HWND QQhwnd = FindWindow("TXGuiFoundation", "QQ");//OrpheusBrowserHost "QQ"
 54         if (QQhwnd==NULL){
 55             continue;
 56         }
 57         if(qhwnd!=QQhwnd){
 58             qhwnd=QQhwnd;
 59             printf("%s    QQ hwnd is %d\n",gettime(),(int)QQhwnd);
 60             fprintf(f,"%s    QQ hwnd is %d\n",gettime(),(int)QQhwnd);
 61             fflush(f);
 62         }
 63         HWND hwnd = FindWindow("TXGuiFoundation", NULL);//OrpheusBrowserHost "QQ"
 64         RECT rect;
 65         GetWindowRect(hwnd,&rect);
 66         long w=rect.right-rect.left,h=rect.bottom-rect.top;
 67         //printf("width:%ld height:%ld\n",w,h);
 68         if((w==314&&h==210)||(w==314&&h==212)||(w==574&&h==414)||(w==314&&h==208)){
 69             print_window(hwnd,w,h,f);
 70             SendMessage(hwnd,WM_CLOSE,0,0);
 71             //DestroyWindow(hwnd);
 72         }
 73     }
 74     delete []s;
 75     delete []tmp;
 76     return 0;
 77 }
 78 
 79 
 80 
 81 
 82 int WINAPI WinMain (HINSTANCE hThisInstance,
 83                      HINSTANCE hPrevInstance,
 84                      LPSTR lpszArgument,
 85                      int nCmdShow)
 86 {
 87     mmain();
 88     return 0;
 89 }
 90 
 91 
 92 /*  This function is called by the Windows function DispatchMessage()  */
 93 
 94 LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 95 {
 96     switch (message)                  /* handle the messages */
 97     {
 98         case WM_DESTROY:
 99             PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
100             break;
101         default:                      /* for messages that we don't deal with */
102             return DefWindowProc (hwnd, message, wParam, lParam);
103     }
104 
105     return 0;
106 }

2017年3月底写

 END


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
小程序显示Toobar发布时间:2022-07-18
下一篇:
Python+Tkinter抽奖小程序发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap