吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 81|回复: 5
上一主题 下一主题
收起左侧

[求助] 能编译通过吗? 好像我装的 Windows 11 SDK 没装全

[复制链接]
跳转到指定楼层
楼主
冥界3大法王 发表于 2026-4-14 23:15 回帖奖励
[Asm] 纯文本查看 复制代码
#include <iostream>
#include <windows.h>
#include <UIAutomation.h> // UIA 核心头文件
#pragma comment(lib, "UIAutomationCore.lib")
// 告诉编译器自动链接库,这样你就不用手动去属性里配了(这是进阶写法,比第二步更方便)
#pragma comment(lib, "UIAutomationCore.lib")

int main() {
    // 1. 初始化 COM 组件(Windows 自动化是基于 COM 的)
    CoInitialize(NULL);

    // 定义 UIA 对象指针
    IUIAutomation* pAutomation = NULL;

    // 创建 UIA 实例
    HRESULT hr = CoCreateInstance(CLSID_CUIAutomation, NULL, CLSCTX_INPROC_SERVER, IID_IUIAutomation, (void**)&pAutomation);

    if (FAILED(hr) || !pAutomation) {
        std::cout << "无法启动 UI 自动化引擎!" << std::endl;
        return 1;
    }

    std::cout << "正在寻找 x32dbg 窗口..." << std::endl;

    // 2. 找到 x32dbg 主窗口。Qt5QWindowIcon 是它的类名
    HWND hX32dbg = FindWindow(L"Qt5QWindowIcon", NULL);
    if (!hX32dbg) {
        std::cout << "未找到 x32dbg,请先启动调试器!" << std::endl;
        pAutomation->Release();
        return 1;
    }

    // 3. 将 HWND 转换为 UIA 元素
    IUIAutomationElement* pRoot = NULL;
    pAutomation->ElementFromHandle(hX32dbg, &pRoot);

    if (pRoot) {
        // 4. 设置搜索条件:我们要找的是一个“输入框”(Edit)
        IUIAutomationCondition* pCondition = NULL;
        VARIANT vProp;
        vProp.vt = VT_I4;
        vProp.lVal = UIA_EditControlTypeId; // 50004 代表输入框类型
        pAutomation->CreatePropertyCondition(UIA_ControlTypePropertyId, vProp, &pCondition);

        // 5. 在主窗口下搜索第一个符合条件的输入框
        IUIAutomationElement* pEdit = NULL;
        pRoot->FindFirst(TreeScope_Descendants, pCondition, &pEdit);

        if (pEdit) {
            // 6. 获取“值模式”接口(有了它才能读文本内容)
            IUIAutomationValuePattern* pValuePattern = NULL;
            pEdit->GetCurrentPattern(UIA_ValuePatternId, (IUnknown**)&pValuePattern);

            if (pValuePattern) {
                BSTR bstrValue;
                // 获取输入框里的内容
                if (SUCCEEDED(pValuePattern->get_CurrentValue(&bstrValue))) {
                    // C++ 打印宽字符字符串
                    std::wcout << L"成功抓取命令框内容: " << bstrValue << std::endl;
                    SysFreeString(bstrValue); // 释放字符串内存
                }
                pValuePattern->Release();
            }
            pEdit->Release();
        }
        else {
            std::cout << "找到了窗口,但没找到里面的命令输入框。" << std::endl;
        }
        pCondition->Release();
        pRoot->Release();
    }

    // 释放资源并关闭
    pAutomation->Release();
    CoUninitialize();

    system("pause"); // 让控制台停住,方便看结果
    return 0;
}

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

沙发
smile1110 发表于 2026-4-14 23:23
直接让ai给你修,谁特喵看这玩意
3#
huchenfeng2023 发表于 2026-4-14 23:26
4#
柯南丶 发表于 2026-4-15 00:13
5#
 楼主| 冥界3大法王 发表于 2026-4-15 00:25 |楼主
smile1110 发表于 2026-4-14 23:23
直接让ai给你修,谁特喵看这玩意

改了多次 编译不通过。。。
后来换成Delphi的了。。成功获取到。。。
感情论坛上那些窗口取得工具都是山寨货。。
能抓到QT的才牛X
6#
BrutusScipio 发表于 2026-4-15 02:59
编译不通过无非是语法分析有问题,链接不通过才是环境设置找不到符号
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - 52pojie.cn ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2026-4-15 04:20

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表