4
我从pip安装了最后一个pywinauto模块。
我不知道如何使用Check(),UnCheck(),GetCheckState()方法。使用pywinauto检查复选框不起作用
这是我非常简单的代码示例。
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()方法,它们也没有工作。
可能你的madHcCtrl.exe只处理WM_CLICK事件来改变状态。这是很常见的情况。如果是的话,还有另一种选择:“CheckByClick”和“UncheckByClick”。 –
它不起作用。我有这个错误:'AttributeError:'HwndWrapper'对象没有属性'CheckByClick'' – baltazer
哦,看起来这个控件被检测为不是复选框。请同时提供'madvr.TCheckBox.Class()'返回值。这可能有助于解决这个pywinauto 0.5.1。 –