#!python3
# -*- coding: utf-8 -*-
"""
Tested for Wireshark 3.0.
Just for fun.
Wireshark can export packets to csv or txt. This is the fastest way.
"""
import os
import sys
import time

sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))  # not required after 'pip install uiautomation'
import uiautomation as auto


def walk():
    wiresharkWindow = None
    for win in auto.GetRootControl().GetChildren():
        if win.ClassName == 'MainWindow' and win.AutomationId == 'MainWindow':
            if win.ToolBarControl(AutomationId='MainWindow.displayFilterToolBar').Exists(0, 0):
                wiresharkWindow = win
                break
    if not wiresharkWindow:
        auto.Logger.WriteLine('Can not find Wireshark', auto.ConsoleColor.Yellow)
        return

    wiresharkWindow.SetActive(waitTime=0.1)
    auto.Logger.ColorfullyWriteLine('Press <Color=Cyan>F1</Color> to stop', auto.ConsoleColor.Yellow)
    tree = wiresharkWindow.TreeControl(searchDepth=4, ClassName='PacketList', Name='Packet list')
    rect = tree.BoundingRectangle
    tree.Click(y=50, waitTime=0.1)
    auto.SendKeys('{Home}', waitTime=0.1)
    columnCount = 0
    treeItemCount = 0
    for item, depth in auto.WalkControl(tree):
        if isinstance(item, auto.HeaderControl):
            columnCount += 1
            auto.Logger.Write(item.Name + ' ')
        elif isinstance(item, auto.TreeItemControl):
            if treeItemCount % columnCount == 0:
                auto.Logger.Write('\n')
                time.sleep(0.1)
            treeItemCount += 1
            auto.Logger.Write(item.Name + ' ')
            if item.BoundingRectangle.bottom >= rect.bottom:
                auto.SendKeys('{PageDown}', waitTime=0.1)
        if auto.IsKeyPressed(auto.Keys.VK_F1):
            auto.Logger.WriteLine('\nF1 pressed', auto.ConsoleColor.Yellow)
            break


if __name__ == '__main__':
    walk()

@@ -786,16 +786,250 @@
 return%0A%0A
+    console = auto.GetConsoleWindow()%0A    if console:%0A        sx, sy = auto.GetScreenSize()%0A        tp = console.GetTransformPattern()%0A        tp.Resize(sx, sy // 4)%0A        tp.Move(0, sy - sy // 4 - 50)%0A        console.SetTopmost()%0A%0A
     wire
@@ -1056,32 +1056,63 @@
 e(waitTime=0.1)%0A
+    wiresharkWindow.Maximize()%0A
     auto.Logger.
@@ -2172,8 +2172,26 @@
  walk()%0A
+    time.sleep(2)%0A

modify a demo