1.UIspy
用这个包的前提是需要定位到每个控件的位置,每个位置都有自己的属性,具体的属性值是需要用UIspy来进行查看的,
查看规则是从大到小,也就是从框架到具体的元素
UIspy的包的获取的相关链接:
https://blog.csdn.net/qq_38161040/article/details/105491034
2.uiautomation的使用
(1)点击计算器
(2)获取cmd信息
在使用过程中,会发现一个问题,一直报没有初始化
OSError: [WinError -2147221008] 尚未调用 CoInitialize。
解决方法,进到comtypes里面加了一句代码:
源代码:
def CoCreateInstance(clsid, interface=None, clsctx=None, punkouter=None):
"""The basic windows api to create a COM class object and return a
pointer to an interface.
"""
if clsctx is None:
clsctx = CLSCTX_SERVER
if interface is None:
interface = IUnknown
p = POINTER(interface)()
iid = interface.iid
_ole32.CoCreateInstance(byref(clsid), punkouter, clsctx, byref(iid), byref(p))
return p
修改后:
def CoCreateInstance(clsid, interface=None, clsctx=None, punkouter=None):
"""The basic windows api to create a COM class object and return a
pointer to an interface.
"""
if clsctx is None:
clsctx = CLSCTX_SERVER
if interface is None:
interface = IUnknown
p = POINTER(interface)()
iid = interface.iid
CoInitialize()
_ole32.CoCreateInstance(byref(clsid), punkouter, clsctx, byref(iid), byref(p))
return p
增加了"CoInitialize()"