我可以用pywinauto自动化Avast Business Antivirus吗?

2024-10-01 02:38:31 发布

您现在位置:Python中文网/ 问答频道 /正文

我经常需要点击Avast Business Antivirus gui来切换特定设置。我想使用pywinauto自动化这个过程,但是我很难在应用程序启动窗口中导航。下图显示了Avast在发布时,我想单击“菜单”按钮(以及随后的其他按钮,但我认为如果我能首先找到菜单按钮,我可以到达那里)

Avast Launch

使用python 3.6.8/pywinauto 0.6.8:

从pywinauto.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()

返回:

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

我看不到任何标识“通知”/“菜单”等的内容。因此我尝试使用“win32”而不是“uia”,但出现以下错误:

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'

Tags: inpyautovenvliblinesiteusers