首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >获取Wireshark PacketList窗口中vScroll向下箭头的中间位置

获取Wireshark PacketList窗口中vScroll向下箭头的中间位置
EN

Stack Overflow用户
提问于 2020-10-12 13:32:46
回答 1查看 81关注 0票数 1
代码语言:javascript
复制
#!/usr/bin/env python
# # myGUI7.py   # use pywinauto to start Wireshark
# Visual Studio Code is Run as Administrator 

import os
import sys

import pywinauto 
from pywinauto.application import Application

# which PyQt5 is needed to be imported?
#from PyQt5 import QtCore, QtWidgets
#from PyQt5.QtGui import *
#from PyQt5.QtWidgets import QAbstractSlider

def process_GUI(pname, fname): 
    # start Wireshark -- it uses Qt5, ergo backend = uia
    app = Application(backend="uia").start(r"C:\\Program Files\\Wireshark\\Wireshark.exe ")
    if app.SoftwareUpdate.exists(timeout=5):
        app.SoftwareUpdate.SkipThisVersion.click()
        app.SoftwareUpdate.Wait_Not('visible') #make sure it is closed
    ##app['The Wireshark Network Analyzer'].print_control_identifiers()

    # open any pcapng file
    win = app["The Wireshark Network Analyzer"]
    win.wait('ready', timeout=5)
    win.type_keys('%F{ENTER}') # Alt+F, Enter (it calls "&File->&Open" menu)
    app.Dialog2.FilenameEdit.set_edit_text(pname + fname)
    app.Dialog2.Open4.click()
    win = app[fname]
    win.wait('ready', timeout=5)
    ##win.print_control_identifiers()

    # get the Packet list window
    PL = win["Packet list"]  # it is a TreeView object  
 
    # how do I get the POINT in middle of Down arrow of vScroll on PL?

# = = = = = = =
if __name__ == '__main__':
    # use path/file of any pcapng that has been saved
    path_name = "C:\\H_Paul\\ws\\"
    file_name = "ws-aug22a_SOsample.pcapng"
    guiReturn = process_GUI(path_name, file_name)
    sys.exit(0)
EN

回答 1

Stack Overflow用户

发布于 2020-10-15 23:54:53

如果您的目标是向下滚动数据包列表,您可以使用

代码语言:javascript
复制
# workaround for set_focus() failure on uia backend
app_win32 = Application(backend="win32").connect(path=r"wireshark.exe")
app_win32.window(best_match='Qt5QWindowIcon').set_focus()
PL.wheel_mouse_input(wheel_dist=-10) # negative wheel_dist means scroll down

或者尝试使用PL.type_keys('{VK_DOWN}')滚动数据包列表。

数据包列表(QTreeView小部件)的IsScrollPatternAvailable属性值为false,因此PL.scroll("down", "line", 1)原因错误消息“树”数据包列表“不可滚动”。此外,inspect.exe不会在PacketList的子级中显示滚动条。

此外,您还可以尝试另一种方法:获取数据包列表的右下角坐标,从中减去(5,5)或其他增量,然后单击到这一点。类似于(这段代码只是演示了idea,因为在最新的Wireshark版本上发送点击到错误的坐标,这可能是一个与Qt相关的问题):

代码语言:javascript
复制
arrow_coords = (PL.rectangle().right - 5, PL.rectangle().bottom - 5)
for i in range(N):
    PL.click_input(coords=arrow_coords)
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64312187

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档