From 309db95069329ce63c9a27ce21993086f2950781 Mon Sep 17 00:00:00 2001 From: Brian Cefali Date: Fri, 27 Sep 2019 14:53:52 -0400 Subject: [PATCH] Added logging --- uiautomation/uiautomation.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/uiautomation/uiautomation.py b/uiautomation/uiautomation.py index b757526..35f5a3c 100644 --- a/uiautomation/uiautomation.py +++ b/uiautomation/uiautomation.py @@ -17,12 +17,14 @@ import time import datetime import re +import logging from typing import (Any, Callable, Iterable, Tuple, List, Dict) # need pip install typing for Python3.4 or lower import ctypes import ctypes.wintypes import comtypes #need pip install comtypes import comtypes.client TreeNode = Any +log = logging.getLogger(__name__) AUTHOR_MAIL = 'yinkaisheng@live.com' @@ -5957,6 +5959,9 @@ def Click(self, x: int = None, y: int = None, ratioX: float = 0.5, ratioY: float point = self.MoveCursorToInnerPos(x, y, ratioX, ratioY, simulateMove) if point: Click(point[0], point[1], waitTime) + else: + log.warning('Failed to move cursor to point at (x, y, ratioX, ratioY, simulateMove), (%s, %s, %s, %s, %s)', + x, y, ratioX, ratioY, simulateMove) def MiddleClick(self, x: int = None, y: int = None, ratioX: float = 0.5, ratioY: float = 0.5, simulateMove: bool = True, waitTime: float = OPERATION_WAIT_TIME) -> None: """ @@ -5974,6 +5979,9 @@ def MiddleClick(self, x: int = None, y: int = None, ratioX: float = 0.5, ratioY: point = self.MoveCursorToInnerPos(x, y, ratioX, ratioY, simulateMove) if point: MiddleClick(point[0], point[1], waitTime) + else: + log.warning('Failed to move cursor to point at (x, y, ratioX, ratioY, simulateMove), (%s, %s, %s, %s, %s)', + x, y, ratioX, ratioY, simulateMove) def RightClick(self, x: int = None, y: int = None, ratioX: float = 0.5, ratioY: float = 0.5, simulateMove: bool = True, waitTime: float = OPERATION_WAIT_TIME) -> None: """ @@ -5991,6 +5999,9 @@ def RightClick(self, x: int = None, y: int = None, ratioX: float = 0.5, ratioY: point = self.MoveCursorToInnerPos(x, y, ratioX, ratioY, simulateMove) if point: RightClick(point[0], point[1], waitTime) + else: + log.warning('Failed to move cursor to point at (x, y, ratioX, ratioY, simulateMove), (%s, %s, %s, %s, %s)', + x, y, ratioX, ratioY, simulateMove) def DoubleClick(self, x: int = None, y: int = None, ratioX: float = 0.5, ratioY: float = 0.5, simulateMove: bool = True, waitTime: float = OPERATION_WAIT_TIME) -> None: """