New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pywinauto script generator #332
Comments
It's a quite complicated task that requires a good discussion at least. The design choice to relay on UIA events is arguable as well. But let's say you started it as a prototype to get deeper insights in the problem )). Regarding the question. I'd expect that StructureChangedEvent will pop-up on its element add/delete but in your example it seems to be disabled. |
On handling WindowClosed events I have only one idea for now. We can remember all the controls properties and especially rectangles (it might be slow though) and then use low level mouse or keyboard events (by This is the main problem in the whole task I think. |
I think it may be necessary to collect all windows and their controls whenever anything changes (probably too complicated) or at least whenever there is no user input for a second (blocking user input while collecting the data) or whenever the user presses a hot-key. |
Hi, @hvbtup most of the core functionality has been already implemented in https://github.com/cetygamer/pywinauto/tree/dev-script-generator/pywinauto/script_generator Main idea: cache tree of application elements with their main properties (position, name, type). Use that tree to determine which element user interacted with and rebuilt the tree whenever we detect 'chage structure' event. |
AFAIK the current implementation has problems with closing elements. I wonder if it could help to detect any screen changes while recording using the "Windows DXGI Desktop Duplication API". BTW this would allow to record the visual appearance as well (capturing images of the screen or of changed parts). When the DXGI API informs us that something changed on the screen, we could inform the recording thread about that fact by setting a "screen_is_dirty" event. The recording thread could wait for that event, and whenever it is set, clear it and take a new snapshot of the structure of the Windows and their controls. |
Can I get this actual code The below link has no code |
The idea is to run an application, do some stuff with it, so generator could detect it and print out python code that would do exactly the same operations.
Currently we are able to catch automation events thrown by automation elements.
https://github.com/cetygamer/pywinauto/tree/dev-script-generator/pywinauto/script_generator
The problem is to handle events which were thrown by closing or already closed automation elements. Even with caching enabled I can't get their properties (to be able to generate pywinauto code). See:
https://github.com/cetygamer/pywinauto/blob/dev-script-generator/pywinauto/script_generator/recorder.py#L130
Example usage:
Example output:
Those empty strings separated by comas are properties of already non-existent automation elements (Help menu, About notepad menu item, About notepad window, Untitled - Notepad window).
@vasily-v-ryabov, @airelil, I could really use some help here.
I could just cache all children of new menus or windows openning, but that wouldn't give me exact information about sender of an event since after window closes all its children get deleted.
The text was updated successfully, but these errors were encountered: