Pywinauto_recorder for Windows¶
“pywinauto_recorder.exe” is a standalone application, it’s the compiled version of “pywinauto_recorder.py” for 64-bit Windows.
“pywinauto_recorder.py” is the main source, you will find the Pyhon code downloading the github clone.
The recorder is started in display information mode, a tray icon is added in the right-side of the Windows Taskbar.
Press CTRL+SHIFT+f to copy the code that finds the element colored green or orange to the clipboard.
Press CTRL+ALT+r to switch to “Record” mode.
If the element below the mouse cursor can be uniquely identified, it will turn green or orange.
You can then click or perform another action on the user interface and it will be recorded in the generated Python script.
Repeat this process performing a few actions on the user interface and when you’re done press CTRL+ALT+r to end recording.
The generated Python script is saved in the “Pywinauto recorder” folder in your home folder and copied in the clipboard.
Click on “Quit” in the tray menu.
To replay a Python script, you can drag and drop it to “pywinauto_recorder.exe”
Pywinauto_recorder_exe does not work on all PCs. If it doesn’t work use the Python version. Help me to find a solution by filling this form.
- Some transparent icons are displayed at the top left of the screen:
an icon corresponds to Record/Stop mode. Press CTRL+ALT+r to switch.
a magnifiying glass icon cooresponds to Display information mode.
a bulb icon corresponds to Smart mode. Press CTRL+ALT+S to activate it.
another icon displays a green bar at each iteration of the loop. It allows you to see how fast the loop is running.
- The main of “Pywinauto recorder” is an infinite loop where at each iteration it:
finds the path of the element under the mouse cursor. The path is formed by the window_text and control_type pair of the element and all its ancestors.
searches for an unambiguous path, if found, it colors the element region green or orange.
records a user action in a file involving the last recognized unique path.
To reflect the position of the mouse cursor as closely as possible, an offset is added to the user actions recorded in the generated Python script. This offset is proportional to the size of the element and relative to the center of the element.
- If the path of the element under the mouse cursor is not ambiguous, the region of the element is colored green. Otherwise two strategies are used to try to disambiguate the path in the following order:
All elements having the same path are ordered in a 2D array. The path of the element region under the mouse cursor is disambiguated by adding a row index and a column index so that it is colored orange. The other element regions are colored red
When Smart mode is enabled, an element whose path is unambiguous is searched on the same line on the left, if found its region is colored blue and the element under the mouse cursor is colored orange.