forked from pywinauto/pywinauto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wait_long_operations.txt
73 lines (48 loc) · 2.72 KB
/
wait_long_operations.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
============================================================
Waiting for Long Operations
============================================================
A GUI application behaviour is often unstable and your script needs
waiting until a new window appears or an existing window is closed/hidden.
pywinauto can wait for a dialog initialization implicitly (with the default
timeout). There are few methods/functions that could help you to make
your code easier and more reliable.
Application methods
-------------------
* WaitCPUUsageLower_ (new in pywinauto 0.5.2)
This method is useful for multi-threaded interfaces that allow a lazy
initialization in another thread while GUI is responsive and all controls
already exist and ready to use. So waiting for a specific window existence/state
is useless. In such case the CPU usage for the whole process indicates that a task
calculation is not finished yet.
Example: ::
app.WaitCPUUsageLower(threshold=5) # wait until CPU usage is lower than 5%
WindowSpecification methods
---------------------------
These methods are available to all controls.
* Wait_
* WaitNot_
There is an example containing long waits: `install script for 7zip 9.20 x64
<https://gist.github.com/vasily-v-ryabov/7a04717af4584cbb840f>`_.
A ``WindowSpecification`` object isn't necessarily related to an existing window/control.
It's just a description namely a couple of criteria to search the window. The ``Wait`` method (if no any exception is raised)
can guarantee that the target control exists or even visible, enabled and/or active.
Functions in ``timings`` module
-------------------------------
There are also low-level methods useful for any Python code.
* WaitUntil_
* WaitUntilPasses_
.. _Wait: code/pywinauto.application.html?highlight=Wait#pywinauto.application.WindowSpecification.Wait
.. _WaitNot: code/pywinauto.application.html?highlight=WaitNot#pywinauto.application.WindowSpecification.WaitNot
.. _WaitCPUUsageLower: code/pywinauto.application.html?highlight=WaitCPUUsageLower#pywinauto.application.Application.WaitCPUUsageLower
.. _WaitUntil: code/pywinauto.timings.html?highlight=WaitUntil#pywinauto.timings.WaitUntil
.. _WaitUntilPasses: code/pywinauto.timings.html?highlight=WaitUntilPasses#pywinauto.timings.WaitUntilPasses
Identify controls
-----------------
The methods to help you to find a needed control.
* PrintControlIdentifiers_
* DrawOutline_
.. _PrintControlIdentifiers: code/pywinauto.application.html?highlight=PrintControlIdentifiers#pywinauto.application.WindowSpecification.PrintControlIdentifiers
.. _DrawOutline: code/pywinauto.controls.HwndWrapper.html?highlight=DrawOutline#pywinauto.controls.HwndWrapper.HwndWrapper.DrawOutline
How To`s
==================
* :doc:`HowTo`