0

一旦以太网属性弹出并可以选择正确的组合列表,任何人都可以帮助我如何切换选项卡。我需要选择共享选项卡,如屏幕截图所示。

提前致谢 !!

代码如下:

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, 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').EthernetHyperlink.invoke()
app.Ethernet_Properties.TabControlNetworking.select("Authentication")
dlp = app.top_window()
dlp.type_keys('ctrl+tab')

在此处输入图像描述

4

1 回答 1

0

您必须以管理员权限运行以下 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 记录器中按了 CTRL+SHIFT+f以轻松识别元素。

于 2021-02-06T23:12:30.370 回答