Iam currently trying to automate a installing process, which I am doing with pywinautogui. I would like to check if a checkbox was checked (which is actually a button), because in some cases the checkbox is alreay checked and it would uncheck it if i pressed it again. is there any way i can figure the state?
app = Application().Start(cmd_line=u'installer.exe')
windowsformswindowappbarad = app[u'Installer']
windowsformswindowappbarad.wait('ready')
windowsformsbuttonappbarad = windowsformswindowappbarad.Button4
#print(checkbox.get_click_state())
windowsformsbuttonappbarad.click()
this is how the Checkbox looks like
Edit:
app = Application().Start(cmd_line=u'installer.exe')
windowsformswindowappbarad = app[u'Installer']
windowsformswindowappbarad.set_focus()
windowsformswindowappbarad.wait('ready')
checkbox_object = windowsformswindowappbarad.Button4()
if checkbox_object.get_toggle_state() == 0:
print("not set")
elif checkbox_object.get_toggle_state() == 1:
print("ein")
With the below code, you can get the Check box state.
Checkbox_object = window_object.wrapper_object()
if checkbox_object.get_toggle_state() == 0:
return False
elif checkbox_object.get_toggle_state() == 1:
return True
Let me know if you face issue .
Below is the code I tried :
from pywinauto.application import Application
app1 = Application(backend='uia').connect(title="H4)")
app1.H4.set_focus()
checkboxobject=app1.Dialog.CheckBox0
value=checkboxobject.get_toggle_state()
print(value)
If value is 0 Check box is not checked , if 1 it is checked