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

Tutorials but Not Work at All ! #1373

Open
QuarTerll opened this issue Jan 31, 2024 · 5 comments
Open

Tutorials but Not Work at All ! #1373

QuarTerll opened this issue Jan 31, 2024 · 5 comments

Comments

@QuarTerll
Copy link

Expected Behavior

print_control_identifiers

Actual Behavior

PS E:\code> python E:\code\win-auto.py
Traceback (most recent call last):
  File "C:\Users\ZJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pywinauto\application.py", line 250, in __resolve_control
    ctrl = wait_until_passes(
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\ZJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pywinauto\timings.py", line 458, in wait_until_passes
    raise err
pywinauto.timings.TimeoutError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "E:\code\win-auto.py", line 7, in <module>
    dlg_spec.print_control_identifiers()
  File "C:\Users\ZJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pywinauto\application.py", line 613, in print_control_identifiers
    this_ctrl = self.__resolve_control(self.criteria)[-1]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ZJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pywinauto\application.py", line 261, in __resolve_control
    raise e.original_exception
  File "C:\Users\ZJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pywinauto\timings.py", line 436, in wait_until_passes
    func_val = func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ZJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pywinauto\application.py", line 203, in __get_ctrl
    dialog = self.backend.generic_wrapper_class(findwindows.find_element(**criteria[0]))
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\ZJ\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\pywinauto\findwindows.py", line 87, in find_element
    raise ElementNotFoundError(kwargs)
pywinauto.findwindows.ElementNotFoundError: {'best_match': '无标题 - 记事本', 'backend': 'uia', 'process': 26536}

Steps to Reproduce the Problem

See code on next section

Short Example of Code to Demonstrate the Problem

from pywinauto.application import Application
import time
app = Application(backend="uia").start('notepad.exe')
# 查到这个记事本的控件树
time.sleep(5)
dlg_spec = app[u'无标题 - 记事本']
dlg_spec.print_control_identifiers()

Specifications

  • Pywinauto version: 0.6.8
  • Python version and bitness: 3.12.1
  • Platform and OS: Microsoft Windows 11 家庭中文版
@QuarTerll
Copy link
Author

image

@QuarTerll
Copy link
Author

@junkmd Can u help me

@junkmd
Copy link
Contributor

junkmd commented Feb 4, 2024

Hi,

I don't have Windows 11, so please keep in mind that this is speculative.

It seems that the reason for the problem may be due to the Notepad GUI modifications made from Windows 11.
https://blogs.windows.com/windows-insider/2023/01/19/tabs-in-notepad-begins-rolling-out-to-windows-insiders/

From what I googled, there also appears to be a way to revert to the "classic version".
https://www.thewindowsclub.com/how-to-restore-the-classic-notepad-in-windows

For now, try changing your Notepad to the classic version in your environment and see if that works.

@juharris
Copy link

juharris commented Mar 5, 2024

I just tried some stuff to manipulate Microsoft Teams in Windows 11 and it worked for me. You can see some examples in https://github.com/onhello-automation/otto/blob/py/python/experiments.ipynb

@junkmd
Copy link
Contributor

junkmd commented Mar 5, 2024

@juharris
Your information seems very helpful.
Pywinauto can work on Windows 11, but I suspect that the codebase that works on Windows 10 (such as examples in tutorials) may not work on Windows 11.

I suspect that the changes in functionality in the notepad application for Windows 11, as compared to Windows 10, may have changes in GUI components and accessibility.
Do you have any information about this?

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

No branches or pull requests

3 participants