当前位置:网站首页>Pywinauto+ an application (learn to lesson 9) -- blocked
Pywinauto+ an application (learn to lesson 9) -- blocked
2022-07-23 11:33:00 【Cheryl_ Xu】
List of articles
- Pywinauto+ An application ( Study until 9 speak )-- Blocked
- The problem is
- 1、 Install third party libraries
- 2、 The entry point of Automation -- back-end technology 、 Number of programs
- 3、 Use of program auxiliary inspection tools --inspect/spy++
- 4、pywinauto Open the specified application --XXX.exe
- 5、pywinauto Connect to an open application -- Window handle 、 process ID
- 6、 Select the window of the application
- 7、 How to operate the window
- 8、 Control selection of window
Pywinauto+ An application ( Study until 9 speak )– Blocked
Blocked point
Use pywinauto,chrome legacy window The lower control cannot be located . Because there are non-standard controls under it , So switch to war pyautogui.
The problem is
1、 Select in the application window , For window type / Window title operation , It's easy to report mistakes .
pywinauto.findbestmatch.MatchError: Could not find 'Chrome_WidgetWin_1' in 'dict_keys(['XXX', 'XXX', 'XXX'])'
At present, only :
dict_keys(['XXX', 'XXX', 'XXX'])
You can't do it with the right window title
2、 When the window is minimized , Unable to restore normal size ; Unable to open the specified application ;
1、 Install third party libraries
1、 Online installation
pip install pywinauto
2、 Offline installation
① Download the package and unzip it
pypi Official website ->pywinauto Search for , download download files-> Extract the underlying folder
② For convenience, the key , Will tar Put the unzipped folder into python Installation directory , namely python Under the directory of the third-party library :D:\python3.6.8\Lib
pywinauto:a set of python modules to automate Microsoft Windows GUI
③cmd Get into AA In the folder , perform python setup.py install Installation
2、 The entry point of Automation – back-end technology 、 Number of programs
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-3m7cjBbq-1656467286084)(C:\Users\Cheryl_Xu\AppData\Roaming\Typora\typora-user-images\image-20220616212917471.png)]](/img/d3/433ff18cd51c5f80a64f555144a4a6.png)
![[ Failed to transfer the external chain picture , The origin station may have anti-theft chain mechanism , It is suggested to save the pictures and upload them directly (img-UBL72akl-1656467044605)(C:\Users\Cheryl_Xu\AppData\Roaming\Typora\typora-user-images\image-20220616213108108.png)]](/img/ec/34267e5ce9b3236dd2c5dd4bc85934.png)
3、 Use of program auxiliary inspection tools –inspect/spy++


inspect: Use UIA Back end parsing technology detects which controls are used .
spy++: Use VS, Automatically this tool , You can judge whether to use win32 Back end parsing technology to parse controls
Both parse the number of controls , Find out Navicat for MYSQL stay inspect There is a more detailed display of controls . And you can also view more detailed window parameters .
4、pywinauto Open the specified application –XXX.exe

from pywinauto.application import Application
# app = Application(backend='uia').start('C:\Program Files\@XXXdesktop\XX.exe'.encode('gb2312').decode('gb2312'))
app = Application(backend='uia').start(r'C:\Program Files\XXXdesktop\XX.exe')
5、pywinauto Connect to an open application – Window handle 、 process ID

# Connect through the process number
app = Application("uia").connect(process=50952)
print(app)
# Connect through the window handle , You can use window sprites to assist
app = Application("uia").connect(handle=400114)
print(app)
6、 Select the window of the application

# Get all the controls of the specified window
# Mode one app[ Window class name / Window title ]: This method is recommended
# Use the class name selection window
dlg=app["Chrome_RenderWidgetHostHWND"]
dlg.print_control_identifiers()
# Select the window through the window title
dlg=app["Chrome Legacy Window"]
dlg.print_control_identifiers()
# Mode two app. Window class name
dlg=app.Chrome_RenderWidgetHostHWND
dlg.print_control_identifiers()
7、 How to operate the window

dlg.maximize() # window maximizing
dlg.minimize() # Minimize the window
dlg.restore() # The window returns to its normal size
# View the display status of the window : Maximize is 1: Normally 0
status=dlg.get_show_state()
print(status)
# Get the coordinates displayed in the current window
rect=dlg.rectangle()
print(rect) # (L63, T567, R1599, B1399)
dlg.close()
8、 Control selection of window
app = Application(backend='uia').start(r'C:\Program Files\XXX\XX.exe')
dlg=app["XXX"]
dlg.print_control_identifiers()
Program all controls
Pane - 'XXX' (L192, T104, R1728, B936)
['XXX', 'XX', 'XXX', 'Pane0', 'Pane1']
child_window(title="XXX", control_type="Pane")
|
| Document - ' ' (L200, T135, R1720, B928)
| [' ', 'Document', ' Document']
| child_window(title=" ", auto_id="88871296", control_type="Document")
|
| Pane - '' (L200, T135, R1720, B928)
| ['Pane2']
|
| TitleBar - '' (L216, T107, R1720, B135)
| ['TitleBar']
| |
| | Menu - ' System ' (L200, T112, R222, B134)
| | [' System Menu', 'Menu', ' System ', ' System 0', ' System 1']
| | child_window(title=" System ", auto_id="MenuBar", control_type="MenuBar")
| | |
| | | MenuItem - ' System ' (L200, T112, R222, B134)
| | | [' System MenuItem', 'MenuItem', ' System 2']
| | | child_window(title=" System ", control_type="MenuItem")
| |
| | Button - ' To minimize the ' (L1581, T105, R1628, B135)
| | [' To minimize the ', ' To minimize the Button', 'Button', 'Button0', 'Button1']
| | child_window(title=" To minimize the ", control_type="Button")
| |
| | Button - ' Maximize ' (L1628, T105, R1674, B135)
| | [' Maximize Button', ' Maximize ', 'Button2']
| | child_window(title=" Maximize ", control_type="Button")
| |
| | Button - ' close ' (L1674, T105, R1721, B135)
| | [' close Button', ' close ', 'Button3']
| | child_window(title=" close ", control_type="Button")
|
| Pane - '' (L200, T135, R1720, B928)
| ['Pane3']
| |
| | Pane - '' (L200, T135, R1720, B928)
| | ['Pane4']
| | |
| | | Pane - '' (L200, T135, R1720, B928)
| | | ['Pane5']
| | | |
| | | | Pane - '' (L200, T135, R1720, B928)
| | | | ['Pane6']
| | | | |
| | | | | Pane - '' (L200, T135, R1720, B928)
| | | | | ['Pane7']
边栏推荐
- JS call, apply, bind
- Understanding of closures of JS
- 数字藏品系统开发:NFT的主要特点有哪些?
- Framework introduction Mvt
- 自定义公式输入框
- TypeScript介绍
- Genesis曾向三箭资本提供23.6亿美元的贷款
- The tree form based on El table and JS xlsx realize the function of downloading excel (II)
- Precautions for realizing "real-time data response" on the page
- 自定义MVC(上)
猜你喜欢
随机推荐
编译原理-语法分析详解
Points for attention when using El table to lazy load tree tables
Genesis曾向三箭资本提供23.6亿美元的贷款
利用动态规划解决最长增长子序列问题
Constructor, prototype chain, instanceof
Flex+js realizes that the height of the internal box follows the maximum height
js中类数组对象以及类数组转换的方法(ES6, ES5)
sql-labs 5-6通关笔记
Two sorting and one random data fetching of stored procedures
Php+ code cloud code hook automatically updates online code
DVWA learning notes
C语言调试常见错误——简答
NepCTF 2022 MISC <签到题>(极限套娃)
MySQL functions & views & import and export
Common bypass methods for file upload vulnerabilities
Analysis of two-part search method or half search method of C language (classic example, classic analysis)
Command Execution Vulnerability and defense
NFT数字藏品平台开发搭建,源码开发数字藏品
activiti7快速入门经验分享
NFT数字藏品系统开发:音乐和NFT的结合









