How to use the uiautomation.Logger.WriteLine function in uiautomation

To help you get started, we’ve selected a few uiautomation examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yinkaisheng / Python-UIAutomation-for-Windows / demos / wireshark_rtp_analyzer.py View on Github external
p.__dict__, diffTimeStamp, p.Time-lastTime, sumTime, sumTimeFromTimeStamp, sumTimeFromTimeStamp - sumTime))
        lastTime = p.Time
        lastTimeStamp = p.TimeStamp
    if frameCount:
        averageDiff = totalDiff // frameCount
        frameCount += 1
        seqCount = packets[-1].Seq - packets[0].Seq + 1
        totalTimeFromTimeStamp = (framePackets[-1].TimeStamp - framePackets[0].TimeStamp) / sampleRate
        realTime = framePackets[-1].Time - framePackets[0].Time
        automation.Logger.ColorfulWriteLine('\n接收包总数: {0}, 帧数: {1}, 实际帧率:{2:.2f}, 平均时间戳: {3}, 接收总时间: {4:.6f}, 时间戳总时间: {5:.6f}, 丢包率: {6}/{7}({8:.2f}%)'.format(
            len(packets), frameCount, frameCount / realTime, averageDiff, realTime, totalTimeFromTimeStamp, len(lostSeqs), seqCount, len(lostSeqs) / seqCount * 100))
        automation.Logger.ColorfulWriteLine('第一个包Seq: {}, TimeStamp: {}, 最后一个包Seq: {}, TimeStamp: {}, 包总数: {}, 丢包数: {}\n'.format(
            packets[0].Seq, packets[0].TimeStamp, packets[-1].Seq, packets[-1].TimeStamp, seqCount, len(lostSeqs)))
        if showLost:
            lostStr = ''.join([('\n' + str(it) + ',') if i % 20 == 0 else (str(it) + ',') for i, it in enumerate(lostSeqs)])
            automation.Logger.WriteLine('丢包序号:\n{}'.format(lostStr))
github yinkaisheng / Python-UIAutomation-for-Windows / demos / expand_tree_item_under_cursor.py View on Github external
def HotKeyFunc(stopEvent: 'Event', argv: list):
    args = [sys.executable, __file__] + argv
    cmd = ' '.join('"{}"'.format(arg) for arg in args)
    auto.Logger.WriteLine('call {}'.format(cmd))
    p = subprocess.Popen(cmd)
    while True:
        if p.poll() is not None:
            break
        if stopEvent.is_set():
            childProcesses = [pro for pro in psutil.process_iter() if pro.ppid == p.pid or pro.pid == p.pid]
            for pro in childProcesses:
                auto.Logger.WriteLine('kill process: {}, {}'.format(pro.pid, pro.cmdline()), auto.ConsoleColor.Yellow)
                p.kill()
            break
        stopEvent.wait(0.05)
    auto.Logger.WriteLine('HotKeyFunc exit')
github yinkaisheng / Python-UIAutomation-for-Windows / demos / expand_tree_item_under_cursor.py View on Github external
def ExpandTreeItem(treeItem: auto.TreeItemControl):
    for item, depth in auto.WalkTree(treeItem, getFirstChild=GetFirstChild, getNextSibling=GetNextSibling, includeTop=True, maxDepth=MaxExpandDepth):
        if isinstance(item, auto.TreeItemControl):  #or item.ControlType == auto.ControlType.TreeItemControl
            if PrintTree:
                auto.Logger.WriteLine(' ' * (depth * 4) + item.Name, logFile='tree_dump.txt')
            sipt = item.GetScrollItemPattern()
            if sipt:
                sipt.ScrollIntoView(waitTime=0.05)
            ecpt = item.GetExpandCollapsePattern()
            if depth < MaxExpandDepth and ecpt and ecpt.ExpandCollapseState == auto.ExpandCollapseState.Collapsed:  # and auto.ExpandCollapseState.Collapsed == item.CurrentExpandCollapseState():
                ecpt.Expand(waitTime=0.05)
github yinkaisheng / Python-UIAutomation-for-Windows / demos / capture_screen.py View on Github external
start = time.time()
    if args.active:
        c = auto.GetForegroundControl()
        CaptureControl(c, args.path, args.up)
    elif args.cursor:
        c = auto.ControlFromCursor()
        CaptureControl(c, args.path, args.up)
    elif args.fullscreen:
        c = auto.GetRootControl()
        rects = auto.GetMonitorsRect()
        dot = args.path.rfind('.')
        for i, rect in enumerate(rects):
            path = args.path[:dot] + '_' * i + args.path[dot:]
            c.CaptureToImage(path, rect.left, rect.top, rect.width(), rect.height())
            auto.Logger.WriteLine('capture image: ' + path)
    auto.Logger.WriteLine('cost time: {:.3f} s'.format(time.time() - start))
github yinkaisheng / Python-UIAutomation-for-Windows / demos / automation_help_demo.py View on Github external
time.sleep(3)
    cmdWindow.SetActive(waitTime = 2)

    thisWindow.SetActive()
    auto.Logger.ColorfullyWrite('run "automation.py" to display the active window\n\n')
    time.sleep(3)

    cmdWindow.SendKeys('"{}" -t3'.format(scriptPath) + '{Enter}', 0.05)
    notepadWindow.SetActive()
    notepadWindow.EditControl().Click()
    time.sleep(3)
    cmdWindow.SetActive(waitTime = 2)
    time.sleep(3)

    thisWindow.SetActive()
    auto.Logger.WriteLine('press Enter to exit', auto.ConsoleColor.Green)
    input()
github yinkaisheng / Python-UIAutomation-for-Windows / demos / wireshark_rtp_analyzer.py View on Github external
def AnalyzePackets(packets, sampleRate, showLost):
    automation.Logger.WriteLine('\n----------\nAnalyze Result:')
    seq = packets[0].Seq - 1
    lostSeqs = []
    framePackets = []
    lastTimeStamp = -1
    for p in packets:
        seq += 1
        if seq != p.Seq:
            lostSeqs.extend(range(seq, p.Seq))
            seq = p.Seq
        if lastTimeStamp < 0:
            framePackets.append(p)
        else:
            if lastTimeStamp == p.TimeStamp:
                framePackets[-1] = p
            else:
                framePackets.append(p)
github yinkaisheng / Python-UIAutomation-for-Windows / demos / get_qq_group_members.py View on Github external
time.sleep(3)
    listItem = automation.ControlFromCursor()
    if listItem.ControlType != automation.ControlType.ListItemControl:
        automation.Logger.WriteLine('没有放在群成员上面,程序退出!')
        return
    consoleWindow = automation.GetConsoleWindow()
    if consoleWindow:
        consoleWindow.SetActive()
    qqWindow = listItem.GetTopWindow()
    list = listItem.GetParentControl()
    allListItems = list.GetChildren()
    for listItem in allListItems:
        automation.Logger.WriteLine(listItem.Name)
    answer = input('是否获取详细信息?按y和Enter继续\n')
    if answer.lower() == 'y':
        automation.Logger.WriteLine('\n3秒后开始获取QQ群成员详细资料,您可以一直按住F10键暂停脚本')
        time.sleep(3)
        qqWindow.SetActive()
		#确保群里第一个成员可见在最上面
        list.Click()
        list.SendKeys('{Home}', waitTime = 1)
        for listItem in allListItems:
            if listItem.ControlType == automation.ControlType.ListItemControl:
                if automation.Win32API.IsKeyPressed(automation.Keys.VK_F10):
                    if consoleWindow:
                        consoleWindow.SetActive()
                    input('\n您暂停了脚本,按Enter继续\n')
                    qqWindow.SetActive()
                listItem.RightClick()
                menu = automation.MenuControl(searchDepth= 1, ClassName = 'TXGuiFoundation')
                menuItems = menu.GetChildren()
                for menuItem in menuItems:
github yinkaisheng / Python-UIAutomation-for-Windows / demos / hide_window_with_hotkey.py View on Github external
def hide():
    root = auto.GetRootControl()
    for window in root.GetChildren():
        if window.ClassName in WindowsWantToHide:
            auto.Logger.WriteLine('hide window, handle {}'.format(window.NativeWindowHandle))
            window.Hide()
            fin = open('hide_windows.txt', 'wt')
            fin.write(str(window.NativeWindowHandle) + '\n')
            fin.close()