Giter VIP home page Giter VIP logo

py_inspect's Introduction

Donate Join the chat at https://gitter.im/pywinauto/pywinauto Documentation Status Windows Tests Linux Tests codecov.io Code Health Codacy Badge Code Quality: Python Total Alerts

pywinauto

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.

Supported technologies under the hood: Win32 API (backend="win32"; used by default), MS UI Automation (backend="uia"). User input emulation modules mouse and keyboard work on both Windows and Linux.

Enjoying this?

Just star the repo or make a donation.

paypal

Your help is valuable since this is a hobby project for all of us: we do new features development during out-of-office hours.

  • In general the library tends to be cross-platform in the near future (Linux in 2018, macOS in 2019).
  • Reliable text based "record-replay" generator is also a high priority feature under development.
  • More feature requests and discusions are welcome in the issues.

Setup

  • run pip install -U pywinauto (dependencies will be installed automatically)

Documentation / Help

Simple Example

It is simple and the resulting scripts are very readable. How simple?

from pywinauto.application import Application
app = Application().start("notepad.exe")

app.UntitledNotepad.menu_select("Help->About Notepad")
app.AboutNotepad.OK.click()
app.UntitledNotepad.Edit.type_keys("pywinauto Works!", with_spaces = True)

MS UI Automation Example

More detailed example for explorer.exe:

from pywinauto import Desktop, Application

Application().start('explorer.exe "C:\\Program Files"')

# connect to another process spawned by explorer.exe
# Note: make sure the script is running as Administrator!
app = Application(backend="uia").connect(path="explorer.exe", title="Program Files")

app.ProgramFiles.set_focus()
common_files = app.ProgramFiles.ItemsView.get_item('Common Files')
common_files.right_click_input()
app.ContextMenu.Properties.invoke()

# this dialog is open in another process (Desktop object doesn't rely on any process id)
Properties = Desktop(backend='uia').Common_Files_Properties
Properties.print_control_identifiers()
Properties.Cancel.click()
Properties.wait_not('visible') # make sure the dialog is closed

Dependencies (if install manually)

  • Windows:
  • Linux:
  • Optional packages:
    • Install Pillow (by pip install -U Pillow) to be able to call capture_as_image() method for making a control's snapshot.

Packages required for running unit tests

Run all the tests: python ./pywinauto/unittests/testall.py

Contribution

Pull requests are very welcome. Read Contribution Guide for more details about unit tests, coding conventions, etc.

Copyrights

Pywinauto for native Windows GUI was initially written by Mark Mc Mahon. Mark brought many great ideas into the life using power of Python. Further contributors are inspired of the nice API so that the development continues.

Starting from 0.6.0 pywinauto is distributed under the BSD 3-clause license. Pywinauto 0.5.4 and before was distributed under the LGPL v2.1 or later.

  • (c) The Open Source Community, 2015-2018 (0.6.0+ development)
  • (c) Intel Corporation, 2015 (0.5.x maintenance)
  • (c) Michael Herrmann, 2012-2013 (0.4.2)
  • (c) Mark Mc Mahon, 2006-2010 (0.4.0 and before)

py_inspect's People

Contributors

dm-vodopyanov avatar radaevvalentin avatar vasily-v-ryabov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

py_inspect's Issues

some suggestion?

I think the main window page of this app should use SplitterView will be better.

Add a refresh button

Please add a refresh button on the Gui so that I can get the latest information of the apps instead of restarting the python work of py_inspect.py. I would appreciate it if you could reply me at your ealiest convenience.

Can't install

ERROR: Could not find a version that satisfies the requirement py_inspect (from versions: none)
ERROR: No matching distribution found for py_inspect

installation info

As a newbie, I've spent some time to understand the installation process. Would you add short explanations to README for better understanding? Something like that:
To install py_inspect:

  1. install required packages (pywinauto, PyQt5 - requirements.txt attached)
  2. download py_inspect.py using one of next options:

Thanks in advance!
Merry Christmas and Happy New Year!

requirements.txt

添加刷新按钮

当我打开新应用或者界面更新时,py_inspect并不提供刷新按钮或定时刷新功能,希望改进,谢谢

Enhancement: Show automation id in ui

I think that using the automation_id can be quite useful for identifying "objects" in a user interface.
Thus showing it in the inspect tool would be quite nice.

TODO

  • Complete code generator & actions
  • Upgrade speed of tree view loading
  • Add splitter view between "Controls view" and "Properties view"; code generator and properties table

Implement lazy loading for elements tree

Currently py_inspect loads the entire elements tree. This significantly increases the program startup time from clicking on the py_inspect.py to the appearance of the main window on the screen.

I think it's need to use a lazy loading strategy for MyTreeModel and the tree_view widget - load child items only when user expands the tree item corresponding for this element. Also, this should eliminate the need to click on the Refresh button in most cases.

The possible approach to implement this can be the overriding of canFetchMore and fetchMore methods in the model class. Or this link can be helpful.

@vasily-v-ryabov @KimNikita

UIAutomationCore.dll is absent

Hi!

I try run py_inspect from Windows 10 and python 3.9.
Here is pip's packets version:

image

When i run py_inspect i got this traceback:


C:\Users\User\git\py_inspect>python py_inspect.py
Traceback (most recent call last):
  File "C:\Users\User\git\py_inspect\py_inspect.py", line 21, in <module>
    from pywinauto import backend
  File "C:\Python39\lib\site-packages\pywinauto\__init__.py", line 89, in <module>
    from . import findwindows
  File "C:\Python39\lib\site-packages\pywinauto\findwindows.py", line 42, in <module>
    from . import controls
  File "C:\Python39\lib\site-packages\pywinauto\controls\__init__.py", line 36, in <module>
    from . import uiawrapper # register "uia" back-end (at the end of uiawrapper module)
  File "C:\Python39\lib\site-packages\pywinauto\controls\uiawrapper.py", line 47, in <module>
    from ..uia_defines import IUIA
  File "C:\Python39\lib\site-packages\pywinauto\uia_defines.py", line 181, in <module>
    pattern_ids = _build_pattern_ids_dic()
  File "C:\Python39\lib\site-packages\pywinauto\uia_defines.py", line 169, in _build_pattern_ids_dic
    if hasattr(IUIA().ui_automation_client, cls_name):
  File "C:\Python39\lib\site-packages\pywinauto\uia_defines.py", line 50, in __call__
    cls._instances[cls] = super(_Singleton, cls).__call__(*args, **kwargs)
  File "C:\Python39\lib\site-packages\pywinauto\uia_defines.py", line 60, in __init__
    self.UIA_dll = comtypes.client.GetModule('UIAutomationCore.dll')
  File "C:\Python39\lib\site-packages\comtypes\client\_generate.py", line 118, in GetModule
    mod = _CreateWrapper(tlib, pathname)
  File "C:\Python39\lib\site-packages\comtypes\client\_generate.py", line 183, in _CreateWrapper
    generate_module(tlib, ofi, pathname)
  File "C:\Python39\lib\site-packages\comtypes\tools\tlbparser.py", line 750, in generate_module
    gen.generate_code(list(items.values()), filename=pathname)
  File "C:\Python39\lib\site-packages\comtypes\tools\codegenerator.py", line 261, in generate_code
    tlib_mtime = os.stat(self.filename).st_mtime
FileNotFoundError: [WinError 2] Не удается найти указанный файл: 'UIAutomationCore.dll'

What i need to do for successfully run the py_inspect?

Is there a fast way to test for the presence of a window/control ?

Is there a fast way to test for the presence of a window/control ?

Using child_window() returns fast because it just defines a spec, but any query on the returned object will take a long time to fail if the spec actually refers to something that's not on-screen.

I'd like to just know whether an element/window is available or not, quickly.
I tried to set allow_magic_lookup=False, but while it fails faster, it still takes a while, and you end-up having to manage a lot of try/except blocks to manage inaccessible elements.

I'm probably missing something, but anyone has any suggestions ?

Is there anything comparable to SWAPY now?

Is there anything comparable to SWAPY now? I would really love some kind of graphical user interface that creates the code for me as I'm automating my desktop environment.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.