• window句柄相关


    微软官方工具(查看程序句柄):

    https://docs.microsoft.com/zh-cn/visualstudio/debugger/using-spy-increment?view=vs-2019

    从 Visual Studio 启动 Spy++

    在“工具”菜单上选择“Spy++” 。

    因为 Spy++ 独立运行,所以在启动之后,可以关闭 Visual Studio。

    第三方教程:

    https://blog.csdn.net/wyplj2015/article/details/107271514/

    获取当前鼠标所在窗口的句柄及窗口标题,并发送信息


    #include <iostream>
    using namespace std;
    #include <Windows.h>

    void getWindows()
    {
    Sleep(3000);

    POINT pNow = { 0,0 };
    if (GetCursorPos(&pNow)) // 获取鼠标当前位置
    {
    HWND hwndPointNow = NULL;
    hwndPointNow = WindowFromPoint(pNow); // 获取鼠标所在窗口的句柄
    if (hwndPointNow)
    {
    cout << "Success!!" << endl;
    char szWindowTitle[50];
    ::GetWindowTextA(hwndPointNow, szWindowTitle, sizeof(szWindowTitle)); // 获取窗口标题
    cout << hex << (int)hwndPointNow << endl; // 鼠标所在窗口的句柄
    cout << szWindowTitle << endl; // 鼠标所在窗口的标题

    //激活窗口

    SetForegroundWindow(hwndPointNow);

    string Name;
    Name = "hello world";
    for (int i = 0; i < Name.length(); i++)
    {

    //发送回车SendMessage如果不行,就换PostMessage

    PostMessage(hwndPointNow, WM_KEYDOWN, VK_RETURN, 0);
    Sleep(100);
    PostMessage(hwndPointNow, WM_KEYUP, VK_RETURN, 0);


    SendMessage(hwndPointNow, WM_CHAR, Name.at(i), 1);
    //SendMessage(hwndPointNow, WM_KEYDOWN, VK_RETURN, 0);
    //SendMessage(hwndPointNow, WM_KEYUP, VK_RETURN, 0);
    }
    }
    else
    cout << "Error!!" << endl;
    }
    else
    cout << "Error!!" << endl;
    }

    int main()
    {
    std::cout << "Hello World! ";
    getWindows();
    }

  • 相关阅读:
    crash reporting system for Windows applications
    1
    qt 试用 (3)配置编译源代码及调试
    kd tree & ray tracing
    new
    KMP算法中关于next数组的探究
    teamviewer vs echovnc
    NAT之stun确定nat类型
    Wireshark
    GNU httptunnel,当SSH被block时的选择
  • 原文地址:https://www.cnblogs.com/mingfuqishi/p/14950554.html
Copyright © 2020-2023  润新知