zoukankan      html  css  js  c++  java
  • 得到指定进程所有窗口。显示 影藏 置顶。

    这里使用一个外挂程序测试,因为外挂程序没有做功能限制的处理 只是做了 窗口影藏。

    全局变量

    HWND hwnd[100]={0};
    int number=0;
    DWORD Tpid=0;

    局部变量

    char username[1028];

    先找到进程ID
     1 HWND SelectPor()
    2 {
    3 bool isYes=false;
    4 string porcessName="可可会员正式版3.04.exe";//可可火影世界辅助会员版
    5 PROCESSENTRY32 lppe;
    6 lppe.dwSize=sizeof(lppe);
    7 HANDLE hsnapshot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
    8 if(hsnapshot==INVALID_HANDLE_VALUE)
    9 {
    10 printf("调用CreateToolhelp32Snapshot失败\n");
    11 }
    12 bool isOK=Process32First(hsnapshot,&lppe);
    13 while(isOK)
    14 {
    15 string name=lppe.szExeFile;
    16 int a=name.compare(porcessName);
    17 if(a==0)
    18 {
    19 printf("这里是SelectPor()进程名:%s\n",lppe.szExeFile);
    20 Tpid=lppe.th32ProcessID;
    21 //HANDLE hanle=getProcessHandle(lppe.th32ParentProcessID);
    22
    23 //HWND txtName=GetWindowByPidc(lppe.th32ParentProcessID);
    24
    25 //printf(":%s\n",txtName);
    26 }
    27 isOK=Process32Next(hsnapshot,&lppe);
    28 }
    29 CloseHandle(hsnapshot);
    30 return NULL;
    31 }
    把指定进程所有窗口句柄存起来
     1 void getstring()
    2 {
    3 if(EnumWindows(EnumWindowsProc,NULL))
    4 {
    5
    6 }
    7 }
    8
    9 BOOL CALLBACK EnumWindowsProc(HWND hwnd,LPARAM lParam)
    10 {
    11 GetWTProcessId(hwnd);
    12 return true;
    13 }
    14
    15 void GetWTProcessId(HWND name)
    16 {
    17 DWORD dwPid,dwTid;
    18 GetWindowThreadProcessId(name,&dwPid);
    19 if(Tpid==dwPid)
    20 {
    21 hwnd[number++]=name;
    22 }
    23 }
    对要操作的窗口进行操作。
     1     if(hwnd!=NULL)
    2 {
    3 for(int i=0;i<number-1;i++)
    4 {
    5 GetWindowText(hwnd[i],username,sizeof(username));
    6 if(_T(username)!=NULL)
    7 {
    8 printf("%s\n",_T(username));
    9 string cmpstr=username;
    10 if(cmpstr.compare("可可登陆界面")==0)
    11 {
    12 ShowWindow(hwnd[i],SW_HIDE)==true?printf("隐藏成功"):printf("隐藏失败");
    13
    14 }
    15 if(cmpstr.compare("可可火影世界辅助会员版")==0)
    16 {
    17 RECT rec;
    18 bool isYEs=false;
    19 GetWindowRect(hwnd[i],&rec);
    20
    21 EnableWindow(hwnd[i],true);
    22
    23 isYEs=SetWindowPos(hwnd[i],HWND_TOPMOST,rec.left,rec.top,rec.right-rec.left,rec.bottom-rec.top,SWP_SHOWWINDOW);
    24 isYEs==true?printf("置顶成功"):printf("置顶失败");
    25 }
    26 }
    27 }
    28 }
  • 相关阅读:
    C++(封装一)
    数据结构之链式栈(二)
    C++(函数重载二)
    不计算阶乘获得结果末尾0的个数
    附加产品
    刘子闻讲的高精度【太强了】
    字符串相关函数
    回文素数
    蛇形填数
    筛法模版
  • 原文地址:https://www.cnblogs.com/yueyue184/p/2285002.html
Copyright © 2011-2022 走看看