
RPA对微信和企业微信的UI元素探测
元素定位原理(用.net自己写一个试一试)
windows10 下UI自动化框架存在于下列路径:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2
2018/03/26 16:24 46,776 UIAutomationClient.dll
2018/03/26 16:24 28,904 UIAutomationClientsideProviders.dll
2018/03/26 16:24 31,424 UIAutomationProvider.dll
2018/03/26 16:24 39,600 UIAutomationTypes.dll
早期我们去探测windows元素用SPY++或者User32.Dll调用可以很方便的获取到句柄
原理如下:鼠标坐标或者标题、类名
[DllImport("user32.dll", EntryPoint = "WindowFromPoint")]//指定坐标处窗体句柄
public static extern int WindowFromPoint(
int xPoint,
int yPoint
);
IntPtr hwnd = WindowFromPoint(point.X, point.Y);//获取指定坐标处窗口的句柄
IntPtr hwnd = Win32.FindWindow(lpszClass, lpWindowName);
由于windows从System.Windows.Forms到Windows.UI.Core 很多自定义的控件出现了,我们无法通过句柄探测到元素。微软的自动化dll对部分UI元素不能获取。
下面是使用了微软UIAutomation 中的 AutomationElement能力对企业微信进行了探测:
AutomationElement element = AutomationElement.FromPoint(new System.Windows.Point(Cursor.Position.X, Cursor.Position.Y));


通过测试无论鼠标定位在哪里,我们探测的始终为顶层菜单。
接下来我使用(影刀、Power Automate、uiBot、实在智能)RPA工具进行了微信及企业微信测试,如下结果:
acc:Windows.UI.Core.CoreWindow
whd:windowsHandle
uia:AutomationElement
cv
影刀







微软Power Automate




uiBot




实在智能




本文探讨了RPA(Robotic Process Automation)在探测微信和企业微信UI元素时遇到的挑战。随着Windows UI框架的发展,传统通过句柄探测元素的方法不再适用。作者介绍了微软的UIAutomation库作为解决方案,但指出它对企业微信的探测存在局限,只能获取顶层菜单。随后,通过比较不同RPA工具(如影刀、PowerAutomate、uiBot和实在智能)在微信和企业微信上的表现,展示了它们在元素探测上的差异。
4万+

被折叠的 条评论
为什么被折叠?



