5

I installed the last pywinauto module from pip.
I don't know how to use the Check(), UnCheck(), GetCheckState() methods.

This is my very simple code sample.

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()

It works if I use the Click() method but this is not what I want.

madvr.TCheckBox.Click()

If the checkbox is already checked it unchecks it.

Why I can't use the Check() method?
I tried with Uncheck() and GetCheckState() methods, they didn't work too.

baltazer
  • 259
  • 1
  • 5
  • 12
  • Probably your madHcCtrl.exe handles only WM_CLICK event for changing the state. This is quite often situation. If yes, there is another option: `CheckByClick` and `UncheckByClick`. – Vasily Ryabov Jul 04 '15 at 07:39
  • It doesn't work too. I've got this error: `AttributeError: 'HwndWrapper' object has no attribute 'CheckByClick'` – baltazer Jul 04 '15 at 12:01
  • Oh, it seems this control is detected as not a check box. Please also provide `madvr.TCheckBox.Class()` return value. It may help to fix this in pywinauto 0.5.1. – Vasily Ryabov Jul 05 '15 at 06:40
  • 1
    It returns: `'TCheckBox'`. – baltazer Jul 05 '15 at 23:59

2 Answers2

3

I've added "TCheckBox" class name to make proper check box detection in 0.5.1 (will be released this week). Thanks for the use case. Currently you may workaround it so (code was updated for pywinauto==0.6.x):

from pywinauto.controls.win32_controls import ButtonWrapper
checkbox = ButtonWrapper(madvr.TCheckBox.wrapper_object())
checkbox.get_check_state()
Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78
3

Try this:

Use get_toggle_state()

checkbox = ButtonWrapper(madvr.TCheckBox.wrapper_object())
checkbox.get_toggle_state()
Adrita Sharma
  • 21,581
  • 10
  • 69
  • 79