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

fix: windows.get_active_window() #333

Conversation

jesicasusanto
Copy link
Collaborator

What kind of change does this PR introduce?

This PR changes the _windows.get_active_window_state() in https://github.com/OpenAdaptAI/OpenAdapt/blob/main/openadapt/window/_windows.py#L31 , to get the top window of the active application. This PR resolves getting the "No windows of that application are active" logger wawrning.

Summary

This PR is a bugfix for #331.

Checklist

  • My code follows the style guidelines of OpenAdapt
  • I have perfomed a self-review of my code
  • If applicable, I have added tests to prove my fix is functional/effective
  • I have linted my code locally prior to submission
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (e.g. README.md, requirements.txt)
  • New and existing unit tests pass locally with my changes

How can your code be run and tested?

Create a new recording on windows, switch to a different application. You should not see the "No windows of that application are active" warning again.

@jesicasusanto jesicasusanto requested a review from abrichr June 30, 2023 05:57
@jesicasusanto jesicasusanto changed the title return top_window of the active app fix windows.get_active_window() Jun 30, 2023
@jesicasusanto
Copy link
Collaborator Author

Result of bugfix :

bugfix.331.-.Made.with.Clipchamp.mp4

@jesicasusanto jesicasusanto mentioned this pull request Jun 30, 2023
7 tasks
@Mustaballer Mustaballer changed the title fix windows.get_active_window() fix: windows.get_active_window() Jun 30, 2023
except RuntimeError as e:
logger.warning(e)
return {}
active_window = get_active_window()
Copy link
Member

Choose a reason for hiding this comment

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

Please handle exception 🙏

@@ -28,7 +28,6 @@ def get_active_window_state() -> dict:
try:
active_window = get_active_window()
except RuntimeError as e:
logger.warning(e)
Copy link
Member

Choose a reason for hiding this comment

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

Thanks @jesicasusanto !

Can you please clarify why this was removed?

@cr-gpt
Copy link

cr-gpt bot commented Jul 11, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@cr-gpt
Copy link

cr-gpt bot commented Jul 12, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@cr-gpt
Copy link

cr-gpt bot commented Jul 12, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

1 similar comment
@cr-gpt
Copy link

cr-gpt bot commented Jul 12, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@jesicasusanto
Copy link
Collaborator Author

  • address *** _ctypes.COMError: (-2147467263, 'Not implemented', (None, None, None, 0, None)) error
    This error is reproduced by getting the selection_indices() property from a <uia_controls.EditWrapper - 'Address and search bar', Edit, -4439357938799333343> element in 3dc81e5
ipdb> getattr(element, propname)()
*** _ctypes.COMError: (-2147467263, 'Not implemented', (None, None, None, 0, None))
ipdb> element
<uia_controls.EditWrapper - 'Address and search bar', Edit, -4439357938799333343>
ipdb> propname
'selection_indices'
  • address *** NotImplementedError: This method not work properly for WinForms DataGrid, use cells()
    ipdb> getattr(element, propname)() in 3dc81e5
*** NotImplementedError: This method not work properly for WinForms DataGrid, use cells()
ipdb> element
<uia_controls.ListViewWrapper - '', Table, -2863142914305943712>
ipdb> propname
'column_count'

@cr-gpt
Copy link

cr-gpt bot commented Jul 12, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

@cr-gpt
Copy link

cr-gpt bot commented Jul 12, 2023

Seems you are using me but didn't get OPENAI_API_KEY seted in Variables/Secrets for this repo. you could follow readme for more information

"""
_element_class = element.__class__
class TempElement(element.__class__):
writable_props = pywinauto.base_wrapper.BaseWrapper.writable_props
Copy link
Member

Choose a reason for hiding this comment

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

Please fix indent

return properties



Copy link
Member

Choose a reason for hiding this comment

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

Please remove extra newline

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

addressed in 6685c36

@abrichr
Copy link
Member

abrichr commented Jul 17, 2023

Excellent, thank you @jesicasusanto !! 🙏

@abrichr abrichr merged commit d3f07c9 into OpenAdaptAI:main Jul 17, 2023
R-ohit-B-isht pushed a commit to R-ohit-B-isht/OpenAdapt that referenced this pull request Jun 21, 2024
* return top_window of the active app

* remove runtime exception

* handle runtime error

* handle COMerror

* add logger.warning

* add logger.warning

* add get_properties

* remove unnecessary imports

* remove -> Desktop

* monkey patching

* fix get_properties

* monkey patch __class__

* fix monkey patching

* format with black
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.

2 participants