J'essaie d'utiliser la méthode IUIAutomation::ElementFromPoint en Python en utilisant comtypes package. Il existe de nombreux exemples d'utilisation en C++, mais pas en Python. Ce code simple reproduit le problème sur Windows 64 bits 10 (Python 2.7 32 bits):Comment passer la structure POINT à la méthode ElementFromPoint en Python?
import comtypes.client
UIA_dll = comtypes.client.GetModule('UIAutomationCore.dll')
UIA_dll.IUIAutomation().ElementFromPoint(10, 10)
Je reçois l'erreur suivante:
TypeError: Expected a COM this pointer as first argument
Création de la structure POINT
cette façon ne permet pas ainsi:
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
Merci, Simon! C'est exactement ce dont j'ai besoin. –