python - 获取 Wireshark PacketList 窗口上 vScroll 向下箭头中间的 POINT
问题描述
#!/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)
解决方案
If your goal is to scroll down Packet List, you can use
# 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
or try PL.type_keys('{VK_DOWN}')
to scroll Packet List.
The value of IsScrollPatternAvailable
property of Packet List (QTreeView widget) is false
, for this reason PL.scroll("down", "line", 1)
cause error message "tree "Packet list" is not scrollable". Also inspect.exe doesn't show scrollbar among PacketList's children.
Also, you can try another approach: get bottom right coordinates of the Packet List, subtract (5,5) or other delta from them and click to this point. Something like (this code just demonstrates idea, because sends click to wrong coordinates on latest Wireshark version, which may be a Qt-related problem):
arrow_coords = (PL.rectangle().right - 5, PL.rectangle().bottom - 5)
for i in range(N):
PL.click_input(coords=arrow_coords)
推荐阅读
- swift - iOS 自定义键盘按钮操作是如何触发的?
- css - 如何修复全屏@keyframes 加载器
- reactjs - 使用 npm init react-app 时,Docker 容器在启动后立即退出
- ruby - 使用 Ruby、PGSql 和 Sinatra 的 new.erb 视图和控制器中的年龄布尔值
- javascript - React 布局帮助 - 无法让我的 SVG 既定尺寸又响应
- numpy - 弃用警告:元素比较失败;这将在未来引发错误。在广播大型阵列时
- ios - APNS 推送通知 iOS 13 - didRegisterForRemoteNotificationsWithDeviceToken 未被调用
- javascript - $.getJSON 中的函数似乎没有运行
- c# - Visual Studio 2019:System.UnauthorizedAccessException:“访问路径“C:/”被拒绝
- python - 在 jupyter 中具有相对路径的 read_csv