Python 3 wrapper of Microsoft UIAutomation. Support UIAutomation for MFC, WindowsForm, WPF, Modern UI(Metro UI), Qt, IE, Firefox, Chrome ...

Overview

The uiautomation module

🇨🇳 中文版介绍

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 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).

I developed it in my spare time and for my personal use.

uiautomation is shared under the Apache Licence 2.0.
This means that the code can be freely copied and distributed, and costs nothing to use.

uiautomation1.x supports py2, py3 and doesn't depend on any third package.

uiautomation2.0+ only supports py3 and depends on comtypes and typing(Python3.5+ built-in).
uiautomation2.0+ is not backward compatible with early versions. See API changes.

You can install uiautomation by "pip install uiautomation". After installation, a automation.py that calls uiautomation will be in 'C:\PythonXX\Scripts'. You use this script to traverse UI controls.

Run 'C:\PythonXX\Scripts\automation.py -h' for help.
Run demos\automation_calculator.py to see a simple demo.

On Windows 8/8.1, to automate a Metro App, the app must be in foreground. If a Metro App was switched to background, uiautomation can't fetch its controls' information.

By the way, You should run python as administrator. Otherwise uiautomation may fail to enumerate controls or get controls' information on Windows 7 or higher.

Requirements:

Microsoft UIAutomation Minimum supported client: Windows 7, Windows Vista with SP2 and Platform Update for Windows Vista, Windows XP with SP3 and Platform Update for Windows Vista [desktop apps only]

Microsoft UIAutomation Minimum supported server: Windows Server 2008 R2, Windows Server 2008 with SP2 and Platform Update for Windows Server 2008, Windows Server 2003 with SP2 and Platform Update for Windows Server 2008 [desktop apps only]

C++ dll source code: UIAutomationClient


How to use uiautomation? run 'automation.py -h' help

Understand the arguments of automation.py, and try the following examples:
automation.py -t 0 -n, print current active window's controls, show fullname
automation.py -r -d 1 -t 0, print desktop(the root of control tree) and it's children(top level windows)

top level windows

automation.py prints the properties of controls and the patterns they support. You use controls and patterns to get controls' information and operate them.

A control should support some patterns or conditionally supports some patterns according to its control type.

patterns

Refer Control Pattern Mapping for UI Automation Clients for the full control pattern table.

uiautomation searches controls from the control tree based on the controls' properties you supply.

Suppose the control tree is

root(Name='Desktop', Depth=0)
  window1(Depth=1)
    control1-001(Depth=2)
    control1-...(Depth=2)
    ...
    control1-100(Depth=2)
  window2(Name='window2', Depth=1)
    control2-1(Depth=2)
      control2-1-001(Depth=3)
      control2-1-...(Depth=3)
      ...
      control2-1-100(Depth=3)
    control2-2(Depth=2)
    control2-3(Depth=2)
    control2-4(Name='2-4', Depth=2)
      editcontrol(Name='myedit1', Depth=3)
      editcontrol(Name='myedit2', Depth=3)

If you want to find the EditControl whose name is 'myedit2' and type 'hi',
you can write the following code:

uiautomation.EditControl(searchDepth=3, Name='myedit2').SendKeys('hi')

But this code run slowly because there are more than 200 controls before myedit2 in the control tree.
uiautomation has to traverse more than 200 controls before finding myedit2 if search from root in 3 search depth.
The better is:

window2 = uiautomation.WindowControl(searchDepth=1, Name='window2') # search 2 times
sub = window2.Control(searchDepth=1, Name='2-4')    # search 4 times
edit = sub.EditControl(searchDepth=1, Name='myedit2')   # search 2 times
edit.SendKeys('hi')

This code run faster than the former.
You can also combine the four lines code into one line.

uiautomation.WindowControl(searchDepth=1, Name='window2').Control(searchDepth=1, Name='2-4').EditControl(searchDepth=1, Name='myedit2').SendKeys('hi')

Now let's take notepad.exe for an example.
Luanch notepad.exe and run automation.py -t 3, then swith to Notepad and wait for 5 seconds

automation.py will print the controls of Notepad and save them to @AutomationLog.txt:

ControlType: PaneControl ClassName: #32769 Name: 桌面 Depth: 0 (Desktop window, the root control)
  ControlType: WindowControl ClassName: Notepad Depth: 1 (Top level window)
    ControlType: EditControl ClassName: Edit Depth: 2
      ControlType: ScrollBarControl ClassName: Depth: 3
        ControlType: ButtonControl ClassName: Depth: 4
        ControlType: ButtonControl ClassName: Depth: 4
      ControlType: ThumbControl ClassName: Depth: 3
    ControlType: TitleBarControl ClassName: Depth: 2
      ControlType: MenuBarControl ClassName: Depth: 3
        ControlType: MenuItemControl ClassName: Depth: 4
      ControlType: ButtonControl ClassName: Name: 最小化 Depth: 3 (Minimize Button)
      ControlType: ButtonControl ClassName: Name: 最大化 Depth: 3 (Maximize Button)
      ControlType: ButtonControl ClassName: Name: 关闭 Depth: 3 (Close Button)
...

Run the following code

# -*- coding: utf-8 -*-
import subprocess
import uiautomation as auto

print(auto.GetRootControl())
subprocess.Popen('notepad.exe')
# you should find the top level window first, then find children from the top level window
notepadWindow = auto.WindowControl(searchDepth=1, ClassName='Notepad')
if not notepadWindow.Exists(3, 1):
    print('Can not find Notepad window')
    exit(0)
print(notepadWindow)
notepadWindow.SetTopmost(True)
# find the first EditControl in notepadWindow
edit = notepadWindow.EditControl()
# use value pattern to get or set value
edit.GetValuePattern().SetValue('Hello')# or edit.GetPattern(auto.PatternId.ValuePattern)
edit.SendKeys('{Ctrl}{End}{Enter}World')
# find the first TitleBarControl in notepadWindow, 
# then find the second ButtonControl in TitleBarControl, which is the Maximize button
notepadWindow.TitleBarControl().ButtonControl(foundIndex=2).Click()
# find the first button in notepadWindow whose Name is '关闭', the close button
# the relative depth from Close button to Notepad window is 2
notepadWindow.ButtonControl(searchDepth=2, Name='关闭').Click()
# then notepad will popup a window askes you to save or not, press hotkey alt+n not to save
auto.SendKeys('{Alt}n')

auto.GetRootControl() returns the root control(the Desktop window)
auto.WindowControl(searchDepth=1, ClassName='Notepad') creates a WindowControl, the parameters specify how to search the control
the following parameters can be used
searchFromControl = None,
searchDepth = 0xFFFFFFFF,
searchInterval = SEARCH_INTERVAL,
foundIndex = 1
Name
SubName
RegexName
ClassName
AutomationId
ControlType
Depth
Compare

See Control.__init__ for the comments of the parameters.
See scripts in folder demos for more examples.

Control.Element returns the low level COM object IUIAutomationElement, Almost all methods and properties of Control are implemented via IUIAutomationElement COM API and Win32 API. when calling a control's method or property that indirectly calls Control.Element and Control.Element is None, uiautomation starts to search the control by the properties you supply. uiautomation will raise a LookupError exception if it can't find the control in uiautomation.TIME_OUT_SECOND(default 10 seconds). Control.Element will has a valid value if uiautomation finds the control successfully. You can use Control.Exists(maxSearchSeconds, searchIntervalSeconds) to check whether a control Exists, this function doesn't raise any exception. Call Control.Refind or Control.Exists to make Control.Element invalid again and uiautomation will starts a new search.

For example:

#!python3
# -*- coding:utf-8 -*-
import subprocess
import uiautomation as auto
auto.uiautomation.SetGlobalSearchTimeout(15)  # set new timeout 15


def main():
    subprocess.Popen('notepad.exe')
    window = auto.WindowControl(searchDepth=1, ClassName='Notepad')
    edit = window.EditControl()
    # when calling SendKeys, uiautomation starts to search window and edit in 15 seconds
    # because SendKeys indirectly calls Control.Element and Control.Element is None
    # if window and edit don't exist in 15 seconds, a LookupError exception will be raised
    try:
        edit.SendKeys('first notepad')
    except LookupError as ex:
        print("The first notepad doesn't exist in 15 seconds")
        return
    # the second call to SendKeys doesn't trigger a search, the previous call makes sure that Control.Element is valid
    edit.SendKeys('{Ctrl}a{Del}')
    window.GetWindowPattern().Close()  # close the first Notepad, window and edit become invalid even though their Elements have a value

    subprocess.Popen('notepad.exe')  # run second Notepad
    window.Refind()  # need to refind window, trigger a new search
    edit.Refind()  # need to refind edit, trigger a new search
    edit.SendKeys('second notepad')
    edit.SendKeys('{Ctrl}a{Del}')
    window.GetWindowPattern().Close()  # close the second Notepad, window and edit become invalid again

    subprocess.Popen('notepad.exe')  # run third Notepad
    if window.Exists(3, 1): # trigger a new search
        if edit.Exists(3):  # trigger a new search
            edit.SendKeys('third notepad')  # edit.Exists makes sure that edit.Element has a valid value now
            edit.SendKeys('{Ctrl}a{Del}')
        window.GetWindowPattern().Close()
    else:
        print("The third notepad doesn't exist in 3 seconds")


if __name__ == '__main__':
    main()

If automation.py can't print the controls you see. Maybe the controls were built by DirectUI(or CustomControl), not UI Frameworks supplied by Microsoft. In order to support UIAutomation, an UI Framework must implement UI Automation Provider.

A Microsoft UI Automation provider is a software object that exposes an element of an application's UI so that accessibility client applications can retrieve information about the element and invoke its functionality. In general, each control or other distinct element in a UI has a provider.

Microsoft includes a provider for each of the standard controls that are supplied with Microsoft Win32, Windows Forms, and Windows Presentation Foundation (WPF). This means that the standard controls are automatically exposed to UI Automation clients; you do not need to implement any accessibility interfaces for the standard controls.

If your application includes any custom controls, you need to implement UI Automation providers for those controls to make them accessible to accessibility client applications. You also need to implement providers for any third party controls that do not include a provider. You implement a provider by implementing UI Automation provider interfaces and control pattern interfaces.


Another UI tool Inspect.exe supplied by Microsoft can also be used to traverse the UI elements. It has an UI interface while my script shows UI elements in terminal. But I found that my script is more convenient sometimes.

Inspect


Some screenshots:

Batch rename pdf bookmark bookmark

Microsoft Word
Word

Wireshark 3.0 (Qt 5.12) Wireshark

GitHub Desktop (Electron App) GitHubDesktop

Pretty print dir
PrettyPrint

Comments
  • AttributeError: '_AutomationClient' object has no attribute 'dll'

    AttributeError: '_AutomationClient' object has no attribute 'dll'

    Hi,

    I am trying to set the module on Windows 10. I am running a python script to open the Notepad and with admin rights, but i received the below log. Am I missing something that needs to be done with the DLL files of the library?

    AutomationClientX86.dll AutomationClientX64.dll

    Are these files already present or should be manually included in the system path?

    Traceback (most recent call last):
      File "automate.py", line 2, in <module>
        import uiautomation as automation
      File "C:\Users\anant.pande\AppData\Roaming\Python\Python35\site-packages\uiautomation.py", line 55, in <module>
        _automationClient = _AutomationClient()
      File "C:\Users\anant.pande\AppData\Roaming\Python\Python35\site-packages\uiautomation.py", line 45, in __init__
        self.dll = ctypes.cdll.UIAutomationClientX64
      File "<C:\Program Files\Anaconda3\lib\ctypes\__init__.py>", line 417, in __getattr__
        dll = self._dlltype(name)
      File "<C:\Program Files\Anaconda3\lib\ctypes\__init__.py>", line 347, in __init__
        self._handle = _dlopen(self._name, mode)
    OSError: [WinError 126] The specified module could not be found
    Exception ignored in: <bound method _AutomationClient.__del__ of <uiautomation._AutomationClient object at 0x000002BF64E952E8>>
    Traceback (most recent call last):
      File "C:\Users\anant.pande\AppData\Roaming\Python\Python35\site-packages\uiautomation.py", line 52, in __del__
        self.dll.ReleaseInstance()
    AttributeError: '_AutomationClient' object has no attribute 'dll' 
    
    opened by vijaysaimutyala 13
  • There is some trouble with AutomationClient.dll has been loaded

    There is some trouble with AutomationClient.dll has been loaded

    Hi Kaisheng,

    In win10, it will show the "WindowsError: [Error 126] The specified module could not be found" hints after processed "import uiautomation as automation";

    I took my attention with KB971513 patch but that would not fit to win10. Specially, on another win10 machine, that works well and didn't pop-up any error hint.

    I guess there is something incompatible with UIAutomationClient.dll but have no idea to fix it; If you are free please have a look at it. Thanks.

    opened by Kunkka1988 11
  • Library Errors out before timeout to find a control not yet present with KeyError: 0

    Library Errors out before timeout to find a control not yet present with KeyError: 0

    Traceback (most recent call last): File "init.py", line 120, in wait_for_control if control.Exists(search_wait_time, uiautomation.SEARCH_INTERVAL): File "C:\Python27\Lib\site-packages\uiautomation\uiautomation.py", line 2424, in Exists control = FindControl(self.searchFromControl, self._CompareFunction, self.searchDepth, False, self.foundIndex) File "C:\Python27\Lib\site-packages\uiautomation\uiautomation.py", line 4299, in FindControl for child, depth in WalkControl(control, findFromSelf, maxDepth): File "C:\Python27\Lib\site-packages\uiautomation\uiautomation.py", line 4185, in WalkControl child = lastControl.GetFirstChildControl() File "C:\Python27\Lib\site-packages\uiautomation\uiautomation.py", line 2670, in GetFirstChildControl return Control.CreateControlFromElement(comEle) File "C:\Python27\Lib\site-packages\uiautomation\uiautomation.py", line 2790, in CreateControlFromElement return ControlDictcontrolType

    opened by akshaykochar 8
  • Any workaround for running 2 apps on one machine with multiple monitors ?

    Any workaround for running 2 apps on one machine with multiple monitors ?

    I'm on a budget I cannot buy more machine, I just have 2 monitors and one machine. I have 2 Windows apps and need to run both in parallel, could I achieve run each app on each monitor by using your library at same time ?

    opened by longk15t 8
  • Cannot run on Win10(works well on Win8.1)

    Cannot run on Win10(works well on Win8.1)

    Python 3.5.2 (v3.5.2:4def2a2901a5, Jun 25 2016, 22:01:18) [MSC v.1900 32 bit (Intel)] on win32 Type "copyright", "credits" or "license()" for more information.

    RESTART: C:\Users\yanglei2\Desktop\Python-UIAutomation-for-Windows-master\automation_notepad_py3.py Traceback (most recent call last): File "C:\Users\yanglei2\Desktop\Python-UIAutomation-for-Windows-master\automation_notepad_py3.py", line 7, in import uiautomation as automation File "C:\Users\yanglei2\Desktop\Python-UIAutomation-for-Windows-master\uiautomation.py", line 55, in _automationClient = AutomationClient() File "C:\Users\yanglei2\Desktop\Python-UIAutomation-for-Windows-master\uiautomation.py", line 43, in init self.dll = ctypes.cdll.UIAutomationClientX86 File "C:\Users\yanglei2\AppData\Local\Programs\Python\Python35-32\lib\ctypes_init.py", line 417, in getattr dll = self.dlltype(name) File "C:\Users\yanglei2\AppData\Local\Programs\Python\Python35-32\lib\ctypes_init.py", line 347, in init self._handle = _dlopen(self._name, mode) OSError: [WinError 126] 找不到指定的模块。

    opened by LeiYangGH 7
  • Win10系统下,多线程中控件获取不到

    Win10系统下,多线程中控件获取不到

    Win7系统下程序执行一切正常,放在Win10系统下程序就会卡住,调试后发现在多线程中控件获取不到,一直处于Connect的状态,比如这样一句代码:automation.WindowControl(searchDepth=1, AutomationId='***', Name=‘***'),不放在线程中执行可以获取到控件,一旦放在线程中执行这样一句代码程序就会卡住,一直处于Connect的状态,不知道是什么原因,请老师指教,谢谢!

    enhancement 
    opened by zhuangyuan1234 6
  • UTF-16 encode/decode issue

    UTF-16 encode/decode issue

    Hey bro! Thanks for your script. But

    I got an issue, I was going to install Intel RealSense SDK core installer but your automation.py does not capture any controls of this window. I got this error message image

    This is the windows I need to interact image

    I guess it includes character ™ and ®so it does not work.

    opened by longk15t 5
  • 【win10环境】导入此库后,获取不到缩放后的分辨率,怎么设置win缩放,125%、150%。得到的都是原始分辨率

    【win10环境】导入此库后,获取不到缩放后的分辨率,怎么设置win缩放,125%、150%。得到的都是原始分辨率

    import ctypes
    import uiautomation as auto
    user32 = ctypes.windll.user32
    gdi32 = ctypes.windll.gdi32
    dc = user32.GetDC(None)
    widthScale = gdi32.GetDeviceCaps(dc, 8)  # 分辨率缩放后的宽度
    heightScale = gdi32.GetDeviceCaps(dc, 10)  # 分辨率缩放后的高度
    width = gdi32.GetDeviceCaps(dc, 118)  # 原始分辨率的宽度
    height = gdi32.GetDeviceCaps(dc, 117)  # 原始分辨率的高度
    scale = width / widthScale
    print(widthScale, heightScale, width, height, scale)
    

    【win10环境】导入此库后,获取不到缩放后的分辨率,怎么设置win缩放,125%、150%。得到的都是原始分辨率

    opened by justyyl 4
  • Not getting DragPattern and DropTargetPattern

    Not getting DragPattern and DropTargetPattern

    Hi @yinkaisheng, I am using control = auto.GetFocusedControl() or other control but not getting DragPatternand DropTargetPattern. I have checked inside the library, and saw, pattern interface was blocked for these 2. Then I tried to unblock these but still not helped. Then I observed, control itself is not returning any pattern for drag and drop because class ControlType: doesn't have entry of drag and drop control.

    Let me clarify question 1 more time, in case above is puzzled. How to get DragPatternand DropTargetPattern from control?

    question 
    opened by sartajg 4
  • Issue with getting right control pattern

    Issue with getting right control pattern

    Hello,

    I have problem with getting Name from "TMemo" element When I try below code:

        panelElement = window.Control(searchDepth=2, ClassName='TdxTabSheet', searchWaitTime=1)
        print(panelElement)
        element = panelElement.Control(searchDepth=2, ClassName='TMemo', searchWaitTime=1)
        print(element)
        element = element.TextControl()
        s = element.GetTextPattern().DocumentRange.GetText(-1)
    

    i receive:

    ControlType: PaneControl    ClassName: TdxTabSheet    AutomationId: 2099786    Rect: (0,99,1920,1017)[1920x918]    Name:  Wyniki weryfikacji     Handle: 0x200A4A(2099786)
    ControlType: EditControl    ClassName: TMemo    AutomationId: 2099648    Rect: (26,896,1894,991)[1868x95]    Name:     Handle: 0x2009C0(2099648)
    2019-07-04 13:18:30.289 pydevd_resolver.py[214] _get_py_dictionary -> Find Control Timeout: {ControlType: TextControl}
    2019-07-04 13:18:40.383 pydevd_resolver.py[214] _get_py_dictionary -> Find Control Timeout: {ControlType: TextControl}
    2019-07-04 13:18:50.494 pydevd_resolver.py[214] _get_py_dictionary -> Find Control Timeout: {ControlType: TextControl}
    2019-07-04 13:19:00.613 pydevd_resolver.py[214] _get_py_dictionary -> Find Control Timeout: {ControlType: TextControl}
    2019-07-04 13:19:10.678 pydevd_resolver.py[214] _get_py_dictionary -> Find Control Timeout: {ControlType: TextControl}
    2019-07-04 13:19:20.742 pydevd_resolver.py[214] _get_py_dictionary -> Find Control Timeout: {ControlType: TextControl}
    2019-07-04 13:19:30.844 pydevd_resolver.py[214] _get_py_dictionary -> Find Control Timeout: {ControlType: TextControl}
    2019-07-04 13:19:40.934 pydevd_resolver.py[214] _get_py_dictionary -> Find Control Timeout: {ControlType: TextControl}
    

    and in UISpy i see at this "TMemo" element that is not Edit but TextPattern.DocumentRange

     Identification
        ClassName:	"TMemo"
        ControlType:	"ControlType.Document"
        Culture:	"(null)"
        AutomationId:	"2099648"
        LocalizedControlType:	"dokument"
        Name:	"Pole nie może być puste."
        ProcessId:	"9860 (P2)"
        RuntimeId:	"42 2099648"
        IsPassword:	"False"
        IsControlElement:	"True"
        IsContentElement:	"True"
    
      Visibility
        BoundingRectangle:	"(26, 896, 1868, 95)"
        ClickablePoint:	"(null)"
        IsOffscreen:	"False"
    
    ControlPatterns
      Text
        DocumentRange
          Text:	"Pole nie może być puste."
          Length:	"24"
          Bounding Rectangles:	"(26, 896, 150, 11)"
          AnimationStyleAttribute:	"(not supported)"
          BackgroundColorAttribute:	"16777215"
          BulletStyleAttribute:	"(not supported)"
          CapStyleAttribute:	"None"
          CultureAttribute:	"(not supported)"
          FontNameAttribute:	"MS Sans Serif"
          FontSizeAttribute:	"8"
          FontWeightAttribute:	"400"
          ForegroundColorAttribute:	"0"
          HorizontalTextAlignmentAttribute:	"Left"
          IndentationFirstLineAttribute:	"(not supported)"
          IndentationLeadingAttribute:	"(not supported)"
          IndentationTrailingAttribute:	"(not supported)"
          IsHiddenAttribute:	"(not supported)"
          IsItalicAttribute:	"False"
          IsReadOnlyAttribute:	"True"
          IsSubscriptAttribute:	"(not supported)"
          IsSuperscriptAttribute:	"(not supported)"
          MarginBottomAttribute:	"(not supported)"
          MarginLeadingAttribute:	"(not supported)"
          MarginTopAttribute:	"(not supported)"
          MarginTrailingAttribute:	"(not supported)"
          OutlineStylesAttribute:	"(not supported)"
          OverlineColorAttribute:	"(not supported)"
          OverlineStyleAttribute:	"(not supported)"
          StrikethroughColorAttribute:	"(not supported)"
          StrikethroughStyleAttribute:	"None"
          TabsAttribute:	"(not supported)"
          TextFlowDirectionsAttribute:	"(not supported)"
          UnderlineColorAttribute:	"(not supported)"
          UnderlineStyleAttribute:	"None"
    

    Do you know reason or workaround for this situation ?

    opened by koroner1 4
  • 使用uiautomation再使用pyautogui这个包会报错

    使用uiautomation再使用pyautogui这个包会报错

    ##示例代码


    ` import uiautomation import pyautogui import time def WalkDesktop(): def GetFirstChild(control): return control.GetFirstChildControl()

    def GetNextSibling(control):
        return control.GetNextSiblingControl()
    
    desktop = uiautomation.GetRootControl()
    for control, depth in uiautomation.WalkTree(desktop, getFirstChildFunc=GetFirstChild, getNextSiblingFunc=GetNextSibling, includeTop=True, maxDepth= 1):
        print(control.ClassName,control.Handle)
    

    WalkDesktop() del WalkDesktop time.sleep(1) pyautogui.click(100,200) ` 报错信息如下: File "D:\Python3.6\lib\site-packages\pyautogui-0.9.40-py3.5.egg\pyautogui_init_.py", line 400, in click File "D:\Python3.6\lib\site-packages\pyautogui-0.9.40-py3.5.egg\pyautogui_init_.py", line 1111, in failSafeCheck File "D:\Python3.6\lib\site-packages\pyautogui-0.9.40-py3.5.egg\pyautogui_init.py", line 237, in position File "D:\Python3.6\lib\site-packages\pyautogui-0.9.40-py3.5.egg\pyautogui_pyautogui_win.py", line 361, in _position ctypes.ArgumentError: argument 1: <class 'TypeError'>: expected LP_Point instance instead of pointer to POINT

    question 
    opened by JackyNiu 4
  • Can not move cursor. PaneControl's BoundingRectangle is (0,0,0,0)[0x0]. SearchProperties: {ControlType: PaneControl}

    Can not move cursor. PaneControl's BoundingRectangle is (0,0,0,0)[0x0]. SearchProperties: {ControlType: PaneControl}

    win_c = auto.WindowControl(searchDepth=10, ClassName="IEFrame").PaneControl(searchDepth=10, ClassName='Frame Tab').PaneControl(searchDepth=10, ClassName="TabWindowClass") pw_input = win_c.GetChildren()[0].GetChildren()[0].GetChildren()[0] is_pw_input = auto.WaitForExist(pw_input, 20) print("-------------------------------------------------------") print(win_c) print("-------------------------------------------------------") print(pw_input) print("-------------------------------------------------------") if is_pw_input: time.sleep(15) pw_input.Click()

    显示已经找到这个元素了,但是在移动点击的时候会报这个错,尝试了好多次都是这样,有什么解决的方法吗?急急急!感谢各位大佬啦~ 鞠躬感谢~

    opened by 123liuyan 0
  • [WinError -2147221008] 尚未调用 CoInitialize

    [WinError -2147221008] 尚未调用 CoInitialize

    一个很奇怪的现象,如果

    import uiautomation
    

    写在自定义函数的外面就会报错,如下

    [WinError -2147221008] 尚未调用 CoInitialize。
    Can not load UIAutomationCore.dll.
    
    1, You may need to install Windows Update KB971513 if your OS is Windows XP, see https://github.com/yinkaisheng/WindowsUpdateKB971513ForIUIAutomation
    
    2, you need to use an UIAutomationInitializerInThread object if use uiautomation in a thread, see demos/uiautomation_in_thread.py
    

    如果写在函数里面就会正常运行。

    这里我主要是寻找一个uwp应用的一个按钮,但是这个按钮没有name属性,也没有automationid属性,所以我是通过他的父类找到他的。代码如下:

    def biliuwp_flash():
    
        #很奇怪,如果import写到外面就无法正常执行
    
        from pydoc import classname
    
        from unicodedata import name
    
        import uiautomation
    
      
    
        biliuwp = uiautomation.WindowControl(Name="哔哩哔哩 UWP",classname="ApplicationFrameTitleBarWindow")
    
        tab = biliuwp.TabControl(classname="Microsoft.UI.Xaml.Controls.TabView",AutomationId="tabView")
    
        flash = tab.GetLastChildControl()
    
        #TODO:想办法加快点击的速度
    
        flash.Click()
    
    opened by 210000ling 0
Owner
yin kaisheng
yin kaisheng
Headless chrome/chromium automation library (unofficial port of puppeteer)

Pyppeteer Pyppeteer has moved to pyppeteer/pyppeteer Unofficial Python port of puppeteer JavaScript (headless) chrome/chromium browser automation libr

miyakogi 3.5k Dec 30, 2022
A friendly wrapper for modern SQLAlchemy and Alembic

A friendly wrapper for modern SQLAlchemy (v1.4 or later) and Alembic. Documentation: https://jpsca.github.io/sqla-wrapper/ Includes: A SQLAlchemy wrap

Juan-Pablo Scaletti 129 Nov 28, 2022
pywinauto is a set of python modules to automate the Microsoft Windows GUI

pywinauto is a set of python modules to automate the Microsoft Windows GUI. At its simplest it allows you to send mouse and keyboard actions to windows dialogs and controls, but it has support for more complex actions like getting text data.

null 3.8k Jan 6, 2023
Ward is a modern test framework for Python with a focus on productivity and readability.

Ward is a modern test framework for Python with a focus on productivity and readability.

Darren Burns 1k Dec 31, 2022
A Proof of concept of a modern python CLI with click, pydantic, rich and anyio

httpcli This project is a proof of concept of a modern python networking cli which can be simple and easy to maintain using some of the best packages

Kevin Tewouda 17 Nov 15, 2022
A modern API testing tool for web applications built with Open API and GraphQL specifications.

Schemathesis Schemathesis is a modern API testing tool for web applications built with Open API and GraphQL specifications. It reads the application s

Schemathesis.io 1.6k Jan 6, 2023
A modern API testing tool for web applications built with Open API and GraphQL specifications.

Schemathesis Schemathesis is a modern API testing tool for web applications built with Open API and GraphQL specifications. It reads the application s

Schemathesis.io 1.6k Dec 30, 2022
The pytest framework makes it easy to write small tests, yet scales to support complex functional testing

The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications and libraries. An example o

pytest-dev 9.6k Jan 2, 2023
Pytest support for asyncio.

pytest-asyncio: pytest support for asyncio pytest-asyncio is an Apache2 licensed library, written in Python, for testing asyncio code with pytest. asy

pytest-dev 1.1k Jan 2, 2023
Python wrapper of Android uiautomator test tool.

uiautomator This module is a Python wrapper of Android uiautomator testing framework. It works on Android 4.1+ (API Level 16~30) simply with Android d

xiaocong 1.9k Dec 30, 2022
Thin-wrapper around the mock package for easier use with pytest

pytest-mock This plugin provides a mocker fixture which is a thin-wrapper around the patching API provided by the mock package: import os class UnixF

pytest-dev 1.5k Jan 5, 2023
PyAutoEasy is a extension / wrapper around the famous PyAutoGUI, a cross-platform GUI automation tool to replace your boooring repetitive tasks.

PyAutoEasy PyAutoEasy is a extension / wrapper around the famous PyAutoGUI, a cross-platform GUI automation tool to replace your boooring repetitive t

Dingu Sagar 7 Oct 27, 2022
A wrapper for webdriver that is a jumping off point for web automation.

Webdriver Automation Plus ===================================== Description: Tests the user can save messages then find them in search and Saved items

null 1 Nov 8, 2021
a wrapper around pytest for executing tests to look for test flakiness and runtime regression

bubblewrap a wrapper around pytest for assessing flakiness and runtime regressions a cs implementations practice project How to Run: First, install de

Anna Nagy 1 Aug 5, 2021
Selenium-python but lighter: Helium is the best Python library for web automation.

Selenium-python but lighter: Helium Selenium-python is great for web automation. Helium makes it easier to use. For example: Under the hood, Helium fo

Michael Herrmann 3.2k Dec 31, 2022
Pynguin, The PYthoN General UnIt Test geNerator is a test-generation tool for Python

Pynguin, the PYthoN General UnIt test geNerator, is a tool that allows developers to generate unit tests automatically.

Chair of Software Engineering II, Uni Passau 997 Jan 6, 2023
Python Projects - Few Python projects with Testing using Pytest

Python_Projects Few Python projects : Fast_API_Docker_PyTest- Just a simple auto

Tal Mogendorff 1 Jan 22, 2022
Green is a clean, colorful, fast python test runner.

Green -- A clean, colorful, fast python test runner. Features Clean - Low redundancy in output. Result statistics for each test is vertically aligned.

Nathan Stocks 756 Dec 22, 2022
Scalable user load testing tool written in Python

Locust Locust is an easy to use, scriptable and scalable performance testing tool. You define the behaviour of your users in regular Python code, inst

Locust.io 20.4k Jan 4, 2023