3 Star 12 Fork 7

Gitee 极速下载 / pywinauto

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/pywinauto/pywinauto
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-3-Clause

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)
Copyright (c) 2017, Mark Mc Mahon and Contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of pywinauto nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

Pywinauto 是基于 Python 开发的,用于自动化测试的脚本模块,主要操作于 Windows 标准图形界面 展开 收起
Python 等 4 种语言
BSD-3-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Python
1
https://gitee.com/mirrors/pywinauto.git
git@gitee.com:mirrors/pywinauto.git
mirrors
pywinauto
pywinauto
atspi

搜索帮助