首页 > 编程语言 > 详细

c++得到窗口句柄

时间:2018-05-09 10:07:51      阅读:259      评论:0      收藏:0      [点我收藏+]
#include <Windows.h>
#include <stdio.h>
#include <tchar.h>
#include <string.h>
#include <iostream>

using namespace std;
int main()
{
    HWND hd = GetDesktopWindow();        //得到桌面窗口
    hd = GetWindow(hd, GW_CHILD);        //得到屏幕上第一个子窗口
    char s[200] = { 0 };
    while (hd != NULL)                    //循环得到所有的子窗口
    {
        memset(s, 0, 200);
        GetWindowText(hd, s, 200);
        if (strcmp(s,"计算器")==0)
        {
            cout << s << endl;
            break;
        }

        
        hd = GetNextWindow(hd, GW_HWNDNEXT);
    }

//    PostMessage(hd, WM_KEYDOWN, 0xd, 0x1C0001);
//    PostMessage(hd, WM_KEYUP, 0xd, 0xC01C0001);

    getchar();
    return 0;
}

 

c++得到窗口句柄

原文:https://www.cnblogs.com/tiandsp/p/9012354.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!