4

我从 pip 安装了最后一个 pywinauto 模块。
我不知道如何使用 Check()、UnCheck()、GetCheckState() 方法。

这是我非常简单的代码示例。

from pywinauto import application

# Start the madvr settings application.
app = application.Application()
app.start_(r'C:\Program Files\LAV Filters\x86\madVR\madHcCtrl.exe editLocalSettingsDontWait')

# Handle the madvr settings window.
madvr = app.window_(title_re="madVR.*")

# Enable the smooth motion tab.
madvr.TreeView.GetItem(r'\rendering\smooth motion').Click()

# Check the smooth motion checkbox.
madvr.TCheckBox.Check()

如果我使用 Click() 方法,它可以工作,但这不是我想要的。

madvr.TCheckBox.Click()

如果复选框已被选中,则取消选中它。

为什么我不能使用 Check() 方法?
我尝试了 Uncheck() 和 GetCheckState() 方法,它们也没有工作。

4

2 回答 2

3

"TCheckBox"在 0.5.1 中添加了类名以进行正确的复选框检测(本周将发布)。感谢您的用例。目前您可以解决它(代码已更新为 pywinauto==0.6.x):

from pywinauto.controls.win32_controls import ButtonWrapper
checkbox = ButtonWrapper(madvr.TCheckBox.wrapper_object())
checkbox.get_check_state()
于 2015-07-06T08:39:43.540 回答
3

试试这个:

采用get_toggle_state()

checkbox = ButtonWrapper(madvr.TCheckBox.wrapper_object())
checkbox.get_toggle_state()
于 2019-05-21T19:00:31.870 回答