我正在尝试在Windows客户端中自动进行适配器设置。
I have written pywinauto(python) code to open till Ethernet Properties
之后,我将无法继续
Process finished with exit code 1
from __future__ import print_function
from pywinauto import Application
# Open "Control Panel"
Application().start('control.exe')
app = Application(backend='uia').connect(path='explorer.exe', title='Control Panel')
# Go to "Programs"
app.window(title="Control Panel").NetworkandInternetHyperlink.invoke()
app.wait_cpu_usage_lower(threshold=0.5, timeout=30, usage_interval=1.0)
#app.window(title='Control Panel').ProgramsHyperlink.invoke()
#app.wait_cpu_usagce_lower(threshold=0.5, timeout=30, usage_interval=1.0)
# Go to "Installed Updates"
app.window(title='Network and Internet').child_window(title='View network status and tasks', control_type='Hyperlink').invoke()
app.wait_cpu_usage_lower(threshold=0.5, timeout=30, usage_interval=1.0)
app.window(title="Network and Sharing Center").ChangeadaptersettingsHyperlink.invoke()
list_box = app.NetworkConnections.FolderViewListBox
# list all updates
items = list_box.descendants(control_type='ListItem')
all_updates = [item.window_text() for item in items]
print('\nAll updates ({}):\n'.format(len(all_updates)))
print(all_updates)
# list updates from "Microsoft Windows" group only
app.window(title='Network Connections').Ethernet0Hyperlink.invoke()
app.window(title="Ethernet0 Status").PropertiesHyperlink.invoke()
app.Ethernet0Properties.Cancel.click() >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>HITTING ERROR
================================================ ==========
E:\ProgramFiles_64\Python\python.exe C:/Users/aerwa/PycharmProjects/Akhil_practice/venv/Scripts/Control_Panel.py
所有更新(3):
['Bluetooth Network Connection', 'Ethernet0', 'Npcap Loopback Adapter']
Traceback (most recent call last):
File "E:\ProgramFiles_64\Python\lib\site-packages\pywinauto\application.py", line 256, in __resolve_control
criteria)
File "E:\ProgramFiles_64\Python\lib\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 "C:/Users/aerwa/PycharmProjects/Akhil_practice/venv/Scripts/Control_Panel.py", line 29, in <module>
app.Ethernet0Properties.Cancel.click()
File "E:\ProgramFiles_64\Python\lib\site-packages\pywinauto\application.py", line 362, in __getattribute__
ctrls = self.__resolve_control(self.criteria)
File "E:\ProgramFiles_64\Python\lib\site-packages\pywinauto\application.py", line 259, in __resolve_control
raise e.original_exception
File "E:\ProgramFiles_64\Python\lib\site-packages\pywinauto\timings.py", line 436, in wait_until_passes
func_val = func(*args, **kwargs)
File "E:\ProgramFiles_64\Python\lib\site-packages\pywinauto\application.py", line 220, in __get_ctrl
ctrl = self.backend.generic_wrapper_class(findwindows.find_element(**ctrl_criteria))
File "E:\ProgramFiles_64\Python\lib\site-packages\pywinauto\findwindows.py", line 84, in find_element
elements = find_elements(**kwargs)
File "E:\ProgramFiles_64\Python\lib\site-packages\pywinauto\findwindows.py", line 303, in find_elements
elements = findbestmatch.find_best_control_matches(best_match, wrapped_elems)
Process finished with exit code 1