如何解决Pywinauto 用于更改多个 Windows 选项卡的多个选项卡
一旦以太网属性弹出并可以选择正确的组合列表,任何人都可以帮助我如何切换选项卡。我需要选择“共享”选项卡,如屏幕截图所示。
提前致谢!!
代码如下:
from __future__ import print_function
import pywinauto,time,keyboard
from pywinauto import Application
from pywinauto.keyboard import send_keys
# 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)
# 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,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').EthernetHyperlink.invoke()
app.Ethernet_Properties.TabControlNetworking.select("Authentication")
dlp = app.top_window()
dlp.type_keys('ctrl+tab')
解决方法
您必须以管理员权限运行以下 Python 代码:
import pywinauto
desktop = pywinauto.Desktop(backend="uia")
window = desktop.windows(title="Control Panel\\All Control Panel Items\\Network Connections",control_type="Window")[0]
sharing_tab = window.descendants(title="Sharing",control_type="TabItem")[0]
sharing_tab.click_input()
我在 Pywinauto recorder 中按了 CTRL+SHIFT+f 以轻松识别元素。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。