Skip to content

2020.6.9拉取最新的变化。 #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jun 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

:cn:[中文版介绍](https://github.com/yinkaisheng/Python-UIAutomation-for-Windows/blob/master/readme_cn.md)

Do not use 3.7.6 and 3.8.1, comtypes doesn't work in these two versions. Install an earlier version or the latest version.
https://github.com/enthought/comtypes/issues/202


This module is for [UIAutomation](https://docs.microsoft.com/en-us/windows/desktop/WinAuto/windows-automation-api-portal) on Windows(Windows XP with SP3, Windows Vista, Windows 7 and Windows 8/8.1/10).
It supports UIAutomation for the applications which implmented UIAutomation Provider, such as MFC, Windows Form, WPF, Modern UI(Metro UI), Qt(Partly), Firefox(**version<=56 or >=60**), Chrome and Electron based apps(require **--force-renderer-accessibility** command line parameter).

Expand Down
14 changes: 10 additions & 4 deletions uiautomation/uiautomation.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,18 +89,20 @@ def __init__(self):
binPath = os.path.join(os.path.dirname(os.path.abspath(__file__)), "bin")
os.environ["PATH"] = binPath + os.pathsep + os.environ["PATH"]
load = False
if sys.version >= '3.8':
os.add_dll_directory(binPath)
if sys.maxsize > 0xFFFFFFFF:
try:
self.dll = ctypes.cdll.UIAutomationClient_VC140_X64
load = True
except OSError as ex:
pass
print(ex)
else:
try:
self.dll = ctypes.cdll.UIAutomationClient_VC140_X86
load = True
except OSError as ex:
pass
print(ex)
if load:
self.dll.BitmapCreate.restype = ctypes.c_size_t
self.dll.BitmapFromWindow.argtypes = (ctypes.c_size_t, ctypes.c_int, ctypes.c_int, ctypes.c_int, ctypes.c_int)
Expand All @@ -116,7 +118,7 @@ def __init__(self):
self.dll.Initialize()
else:
self.dll = None
Logger.WriteLine('Can not load dll.\nFunctionalities related to Bitmap are not available.\nYou may need to install Microsoft Visual C++ 2010/2015 Redistributable Package.', ConsoleColor.Yellow)
Logger.WriteLine('Can not load dll.\nFunctionalities related to Bitmap are not available.\nYou may need to install Microsoft Visual C++ 2015 Redistributable Package.', ConsoleColor.Yellow)
def __del__(self):
if self.dll:
self.dll.Uninitialize()
Expand Down Expand Up @@ -1680,6 +1682,9 @@ def ycenter(self) -> int:

def contains(self, x: int, y: int) -> bool:
return self.left <= x < self.right and self.top <= y < self.bottom

def __eq__(self, rect):
return self.left == rect.left and self.top == rect.top and self.right == rect.right and self.bottom == rect.bottom

def __str__(self) -> str:
return '({},{},{},{})[{}x{}]'.format(self.left, self.top, self.right, self.bottom, self.width(), self.height())
Expand Down Expand Up @@ -2778,6 +2783,7 @@ def Write(log: Any, consoleColor: int = ConsoleColor.Default, writeToFile: bool
if not writeToFile:
return
fileName = logFile if logFile else Logger.FileName
fout = None
try:
fout = open(fileName, 'a+', encoding='utf-8')
fout.write(log)
Expand Down Expand Up @@ -6867,7 +6873,7 @@ def IsMaximize(self) -> bool:

def Minimize(self, waitTime: float = OPERATION_WAIT_TIME) -> bool:
if self.IsTopLevel():
return self.ShowWindow(SW.Restore, waitTime)
return self.ShowWindow(SW.Minimize, waitTime)
return False

def IsMinimize(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion uiautomation/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "2.0.4"
VERSION = "2.0.5"