I often have to click through the Avast Business Antivirus gui to toggle a specific setting. I want to automate this process using pywinauto but I'm having a hard time navigating the application launch window. The image below shows Avast at launch, I want to click the 'Menu' button (and subsequently other buttons but I think I can get there if I can figure out the Menu button first).
Using python 3.6.8 / pywinauto 0.6.8:
from pywinauto.application import Application
app = Application(backend='uia').start('C:\Program Files\AVAST Software\Avast\AvastUI.exe').connect(title='Avast Business Antivirus',timeout=100)
app.AvastBusinessAntivirus.print_control_identifiers()
Returns:
Control Identifiers:
Dialog - 'Avast Business Antivirus' (L169, T143, R1431, B985)
['Dialog', 'Avast Business Antivirus', 'Avast Business AntivirusDow")
|
| Pane - 'AvastChromiumWindow' (L169, T143, R1431, B985)
| ['Pane', 'AvastChromiumWindow', 'AvastChromiumWindowPane', 'Pane0', 'Pane1']
| child_window(title="AvastChromiumWindow", control_type="Pane")
| |
| | Pane - '' (L169, T143, R1431, B985)
| | ['Pane2']
| | |
2, B986)
| | | ['Pane3', 'Chrome Legacy Window', 'Chrome Legacy WindowPane']
| | | child_window(title="Chrome Legacy Window", auto_id="1002608416", control_type="Pane")
I don't see anything identifying 'Notification'/'Menu'/etc. So I tried using 'win32' instead of 'uia' but got the error below:
Control Identifiers:
Traceback (most recent call last):
File ".\webshare.py", line 4, in <module>
app.AvastBusinessAntivirus.print_control_identifiers()
File "C:\Users\greg_\Desktop\projects\avast_auto\.venv\lib\site-packages\pywinauto\application.py", line 689, in print_control_identifiers
print_identifiers([this_ctrl, ])
File "C:\Users\greg_\Desktop\projects\avast_auto\.venv\lib\site-packages\pywinauto\application.py", line 660, in print_identifiers
if hasattr(ctrl.element_info, 'automation_id'):
File "C:\Users\greg_\Desktop\projects\avast_auto\.venv\lib\site-packages\pywinauto\win32_element_info.py", line 201, in automation_id
remote_mem = RemoteMemoryBlock(self, size=length*2)
File "C:\Users\greg_\Desktop\projects\avast_auto\.venv\lib\site-packages\pywinauto\remote_memory_block.py", line 112, in __init__
if hex(self.mem_address) == '0xffffffff80000000' or hex(self.mem_address).upper() == '0xFFFFFFFF00000000':
TypeError: 'NoneType' object cannot be interpreted as an integer
Exception ignored in: <bound method RemoteMemoryBlock.__del__ of
<pywinauto.remote_memory_block.RemoteMemoryBlock object at 0x00000182616217B8>>
Traceback (most recent call last):
File "C:\Users\greg_\Desktop\projects\avast_auto\.venv\lib\site-packages\pywinauto\remote_memory_block.py", line 170, in __del__ self.CleanUp()
File "C:\Users\greg_\Desktop\projects\avast_auto\.venv\lib\site-packages\pywinauto\remote_memory_block.py", line 147, in CleanUp self.CheckGuardSignature()
File "C:\Users\greg_\Desktop\projects\avast_auto\.venv\lib\site-packages\pywinauto\remote_memory_block.py", line 286, in CheckGuardSignature
c_void_p(self.mem_address + self.size),
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
