我试图使用comtypes包使用方法在Python IUIAutomation::ElementFromPoint。有很多例子说明如何在C++中使用它,但不在Python中使用它。这个简单的代码重新在64位Windows 10中的问题(Python 2.7版32位):如何在Python中将POINT结构传递给ElementFromPoint方法?
import comtypes.client
UIA_dll = comtypes.client.GetModule('UIAutomationCore.dll')
UIA_dll.IUIAutomation().ElementFromPoint(10, 10)
我得到以下错误:
TypeError: Expected a COM this pointer as first argument
创建POINT
结构这种方式并不能帮助还有:
from ctypes import Structure, c_long
class POINT(Structure):
_pack_ = 4
_fields_ = [
('x', c_long),
('y', c_long),
]
point = POINT(10, 10)
UIA_dll.IUIAutomation().ElementFromPoint(point) # raises the same exception
谢谢,西蒙!这正是我需要的。 –