Skip to content
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

Implement native backend for WPF applications #1210

Draft
wants to merge 59 commits into
base: atspi
Choose a base branch
from

Conversation

eltimen
Copy link
Contributor

@eltimen eltimen commented May 4, 2022

This backend uses .NET DLL injection to find WPF widgets, get their properties and perform actions on them.

TODOs:

  • Add wrapper for grid widgets (ListView in GridView mode, DataGrid)
  • Add sample apps and some unit tests for some custom WPF controls frameworks such as DevExpress, Infragistics, ...
  • Fix .type_keys() sporadic unit test failure (self-resolved?)
  • Update injected submodule

pywinauto/controls/wpf_controls.py Outdated Show resolved Hide resolved
pywinauto/controls/wpf_controls.py Outdated Show resolved Hide resolved
@vasily-v-ryabov
Copy link
Contributor

Also "1 new alert" is found by LGTM.

pywinauto/controls/wpf_controls.py Show resolved Hide resolved
pywinauto/controls/wpf_controls.py Outdated Show resolved Hide resolved
pywinauto/controls/wpf_controls.py Outdated Show resolved Hide resolved
pywinauto/controls/wpf_controls.py Outdated Show resolved Hide resolved
pywinauto/controls/wpf_controls.py Outdated Show resolved Hide resolved
for i in range(1, items_cnt):
menu = next_level_menu(menu, menu_items[i], items_cnt == i + 1)
except AttributeError:
raise IndexError()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any error message? Or maybe better forward it from AttributeError object?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These lines is copied from the same method from UIA backend (uia_controls.py, line 1129).
Is it need to add error messages to the UIA-related method too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be nice to do it in both places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Note: these exceptions are usually raised when trying to access field of None value, wrong index in a list, etc. I added the variable to store index of the current item in menu path and use this index in the raised exception message.

pywinauto/controls/wpfwrapper.py Outdated Show resolved Hide resolved
pywinauto/controls/wpfwrapper.py Show resolved Hide resolved
pywinauto/controls/wpfwrapper.py Show resolved Hide resolved
pywinauto/controls/wpfwrapper.py Show resolved Hide resolved
@eltimen eltimen force-pushed the dotnet-injector-backend branch 3 times, most recently from 2b1749d to dba70a8 Compare June 23, 2022 19:20
@eltimen eltimen changed the title WIP: Implement native backend for WPF applications Implement native backend for WPF applications Aug 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants