win32-UI Automation
使用UI Automation遍历窗口的所有控件标题和类
#include <Windows.h>
#include <stdio.h>
#include <UIAutomation.h> IUIAutomation* pClientUIA;
IUIAutomationElement* pRootElement; void FindControl(const long controlType)
{
HRESULT hr;
BSTR name;
IUIAutomationCondition* pCondition;
VARIANT varProp;
varProp.vt = VT_I4;
varProp.uintVal = controlType;
hr = pClientUIA->CreatePropertyCondition(UIA_ControlTypePropertyId, varProp, &pCondition);
if (S_OK != hr)
{
printf("CreatePropertyCondition error: %d\n", GetLastError());
} IUIAutomationElementArray* pElementFound;
hr = pRootElement->FindAll(TreeScope_Subtree, pCondition, &pElementFound);
if (S_OK != hr)
{
printf("CreatePropertyCondition error: %d\n", GetLastError());
}
int eleCount;
pElementFound->get_Length(&eleCount);
for (int i = 0; i <= eleCount; i++)
{
IUIAutomationElement* pElement;
hr = pElementFound->GetElement(i, &pElement);
if (S_OK != hr)
{
printf("CreatePropertyCondition error: %d\n", GetLastError());
}
hr = pElement->get_CurrentName(&name);
if (S_OK != hr)
{
printf("CreatePropertyCondition error: %d\n", GetLastError());
}
wprintf(L"Control Name: %s\n", name);
hr = pElement->get_CurrentClassName(&name);
if (S_OK != hr)
{
printf("CreatePropertyCondition error: %d\n", GetLastError());
}
wprintf(L"Class Name: %s\n", name);
}
} int main()
{
HRESULT hr = CoInitializeEx(NULL, COINITBASE_MULTITHREADED | COINIT_DISABLE_OLE1DDE);
if (S_OK != hr)
{
printf("CoInitializeEx error: %d\n", GetLastError());
return 1;
} hr = CoCreateInstance(CLSID_CUIAutomation, NULL, CLSCTX_INPROC_SERVER, IID_IUIAutomation, reinterpret_cast<void**>(&pClientUIA));
if (S_OK != hr)
{
printf("CoCreateInstance error: %d\n", GetLastError());
return 1;
} HWND hwnd = (HWND)0x00030AF6;
if (hwnd == NULL)
{
printf("FindWindow error: %d\n", GetLastError());
return 1;
} hr = pClientUIA->ElementFromHandle(hwnd, &pRootElement);
if (S_OK != hr)
{
printf("ElementFromHandle error: %d\n", GetLastError());
return 1;
} FindControl(UIA_TextControlTypeId);
}
win32-UI Automation的更多相关文章
- 使用UI Automation实现自动化测试 --工具使用
当前项目进行三个多月了,好久也没有写日志了:空下点时间,补写下N久没写的日志 介绍下两个工具 我本人正常使用的UISpy.exe工具和inspect.exe工具 这是UISPY工具使用的图,正常使用到 ...
- Client-Side UI Automation Provider - WinForm Sample
Client-Side UI Automation Provider - WinForm Sample 2014-09-15 源代码 目录 引用程序集实现提供程序接口分发客户端提供程序注册和配置客户 ...
- 从UI Automation看Windows平台自动化测试原理
前言 楼主在2013年初研究Android自动化测试的时候,就分享了几篇文章 Android ViewTree and DecorView Android自动化追本溯源系列(1): 获取页面元素 An ...
- 开源自己用python封装的一个Windows GUI(UI Automation)自动化工具,支持MFC,Windows Forms,WPF,Metro,Qt
首先,大家可以看下这个链接 Windows GUI自动化测试技术的比较和展望 . 这篇文章介绍了Windows中GUI自动化的三种技术:Windows API, MSAA - Microsoft Ac ...
- 使用UI Automation实现自动化测试--1-4
Introduction UI Automation是Microsoft .NET 3.0框架下提供的一种用于自动化测试的技术,是在MSAA基础上建立的,MSAA就是Microsoft Active ...
- 使用UI Automation实现自动化测试--5-7
使用UI Automation实现自动化测试--5 (Winfrom和WPF中弹出和关闭对话框的不同处理方式) 在使用UI Automation对Winform和WPF的程序测试中发现有一些不同的地方 ...
- UI Automation Test
UI Automation test is based on the windows API. U can find the UI Automation MSDN file from http://m ...
- UI Automation 简介
转载,源地址: http://blog.csdn.net/ffeiffei/article/details/6637418 MS UI Automation(Microsoft User Interf ...
- MS UI Automation Introduction
MS UI Automation Introduction 2014-09-17 MS UI Automation是什么 UIA架构 UI自动化模型 UI自动化树概述 UI自动化控件模式概述 UI 自 ...
- Server-Side UI Automation Provider - WPF Sample
Server-Side UI Automation Provider - WPF Sample 2014-09-14 引用程序集 自动化对等类 WPF Sample 参考 引用程序集 返回 UIAut ...
随机推荐
- [转帖]jmeter之使用csv文件传递参数-05篇
csv文件格式,第一列为手机号,第二列为密码 1.右键添加一个配置元件---csv数据文件设置 2.设置csv数据提取路径 3.引用数据 4.设置线程循环运行两次,然后发送请求 看到结果就执行了两次, ...
- [转帖]解决vCenter6.x由于证书过期问题无法登录
https://www.dinghui.org/vcenter-sts-certificate.html#:~:text=%E8%BF%99%E6%97%B6%E5%80%99%EF%BC%8C%E5 ...
- [转帖]linux时间戳转换成时间指令_时间戳转换公式
原文地址:http://wanping.blogbus.com/logs/28663569.html 1.时间戳转换为正常显示的时间格式 Freebsd 系统下: 转换命令为: date -r 111 ...
- node中的优先从缓存中加载模块与模块的加载规则
执行 node main.js 请问 b模块会被加载几次 //main.js require('./a.js') var fn = require('./b.js') console.log(fn.s ...
- js加减乘除运算出现精度丢失
做乘法运算出现精度丢失 let aa= 2106.49 console.log( aa*10000 ) //21064899.999999996 console.log( Math.round(aa* ...
- spring boot设置日志打印为控制台输出和文件输出
日志打印 sources里建logback-spring.xml <?xml version="1.0" encoding="UTF-8"?> &l ...
- 热门数据集提供【MNIST、鸢尾花、猫狗、CIFAR10、vegetables、Ox-Flowers17、pascalvoc】
热门数据集提供[MNIST.鸢尾花.猫狗.CIFAR10.vegetables.Ox-Flowers17.pascalvoc] 简介: 鸢尾花数据集: 约150条数据,每条样本4个属性,共3个类别 M ...
- Win32汇编:数组与标志位测试总结
整理复习汇编语言的知识点,以前在学习<Intel汇编语言程序设计 - 第五版>时没有很认真的整理笔记,主要因为当时是以学习理解为目的没有整理的很详细,这次是我第三次阅读此书,每一次阅读都会 ...
- pywin32 实现寻找窗体并模拟按键
import win32api import win32gui, win32con import win32clipboard import re import time class cWindow: ...
- 在K8S中,PV和PVC是如何关联?
在Kubernetes(简称K8s)中,PersistentVolume (PV) 和 PersistentVolumeClaim (PVC) 是实现存储持久化的关键组件.它们之间的关联是用来动态或静 ...