zoukankan      html  css  js  c++  java
  • 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();
    }

  • 相关阅读:
    sql server获取指定库下的所有表名
    sql根据字符将一行拆成多行
    刷题416. Partition Equal Subset Sum
    刷题394. Decode String
    刷题347. Top K Frequent Elements
    刷题309. Best Time to Buy and Sell Stock with Cooldown
    刷题338. Counting Bits
    刷题337. House Robber III
    刷题312. Burst Balloons
    刷题621. Task Scheduler
  • 原文地址:https://www.cnblogs.com/mingfuqishi/p/14950554.html
Copyright © 2011-2022 走看看