예제 #1
0
def DetectZoomMeeting():
  global zoomToolbarOpen
  global zoomMeetingOpen

  if debug == True:
    global start
    start = time.time()
  zoomMeetingInProgress = False
  def GetFirstChild(control):
    return control.GetFirstChildControl()
  def GetNextSibling(control):
    return control.GetNextSiblingControl()
  desktop = automation.GetRootControl()

  zoomMeetingOpen = False
  zoomToolbarOpen = False
  for control, depth in automation.WalkTree(desktop, getFirstChild=GetFirstChild, getNextSibling=GetNextSibling, includeTop=False, maxDepth=2):
    if debug == True:
      print(str(depth) + ' ' * depth * 4 + str(control))
    if str(control).find("ZPContentViewWndClass") > 0:
      zoomMeetingInProgress = True
      zoomMeetingOpen = True
    if str(control).find("ZPFloatToolbarClass") > 0:
      zoomMeetingInProgress = True
      zoomToolbarOpen = True
  return zoomMeetingInProgress
예제 #2
0
def main(directory, maxDepth=0xFFFFFFFF):
    remain = {}
    texts = []
    absdir = os.path.abspath(directory)
    for it, depth, remainCount in auto.WalkTree(absdir,
                                                getChildren=GetDirChildren,
                                                includeTop=True,
                                                maxDepth=maxDepth):
        remain[depth] = remainCount
        isDir = os.path.isdir(it)
        prefixLog = ''.join(
            ['│   ' if remain[i + 1] else '    ' for i in range(depth - 1)])
        prefixPrint = prefixLog
        if depth > 0:
            if remain[depth] > 0:
                prefixPrint += '├─→' if isDir else '├── '
                prefixLog += '├─→ ' if isDir else '├── '
            else:
                prefixPrint += '└─→' if isDir else '└── '
                prefixLog += '└─→ ' if isDir else '└── '
        file = os.path.basename(it)
        texts.append(prefixLog)
        texts.append(file)
        texts.append('\n')
        auto.Logger.Write(prefixPrint, writeToFile=False)
        auto.Logger.WriteLine(
            file,
            auto.ConsoleColor.Cyan if isDir else auto.ConsoleColor.Default,
            writeToFile=False)
    allText = ''.join(texts)
    auto.Logger.WriteLine(allText, printToStdout=False)
    ret = input(
        '\npress Y to save dir tree to clipboard, press other keys to exit')
    if ret.lower() == 'y':
        auto.SetClipboardText(allText)
def WalkQueens(queenCount = 8):
    def GetNextQueenColumns(place):
        notValid = set()
        nextRow = len(place)
        for i in range(nextRow):
            leftDiagonal = place[i] - (nextRow - i)
            if leftDiagonal >= 0:
                notValid.add(leftDiagonal)
            notValid.add(place[i])
            rightDiagonal = place[i] + (nextRow - i)
            if rightDiagonal < queenCount:
                notValid.add(rightDiagonal)
        return [x for x in range(queenCount) if x not in notValid]

    def GetNextQueens(place):
        places = []
        if len(place) == 0:
            for i in range(queenCount):
                places.append([i])
        else:
            valid = GetNextQueenColumns(place)
            for x in valid:
                newPlace = place[:]
                newPlace.append(x)
                places.append(newPlace)
        return places

    count = 0
    for queens, depth, remain in automation.WalkTree([], GetNextQueens, yieldCondition=lambda c, d: d == queenCount):
        count += 1
        automation.Logger.WriteLine(count, automation.ConsoleColor.Cyan)
        for x in queens:
            automation.Logger.ColorfullyWriteLine('o ' * x + '<Color=Cyan>x </Color>' + 'o ' * (queenCount - x - 1))
예제 #4
0
def main(directory, maxDepth=0xFFFFFFFF):
    remain = {}
    text = []
    absdir = os.path.abspath(directory)
    for it, depth, remainCount in automation.WalkTree(
            absdir,
            getChildrenFunc=GetDirChildren,
            includeTop=True,
            maxDepth=maxDepth):
        remain[depth] = remainCount
        isDir = os.path.isdir(it)
        prefix = ''.join([
            '│   ' if remain[i + 1] else '    ' for i in range(depth - 1)
        ])  # u'│   ' for python 2
        if depth > 0:
            if remain[depth] > 0:
                prefix += '├─→ ' if isDir else '├── '  #'□─→ ' # u'├─→ ' for python 2
            else:
                prefix += '└─→ ' if isDir else '└── '  #'□─→ ' # u'└─→ ' for python 2
        file = it[it.rfind('\\') + 1:]
        text.append(prefix)
        text.append(file)
        text.append('\r\n')
        automation.Logger.Write(prefix)
        automation.Logger.WriteLine(
            file, automation.ConsoleColor.Cyan if os.path.isdir(it) else -1)
    automation.SetClipboardText(''.join(text))
예제 #5
0
def DetectZoomMeeting():
    if debug:
        global start
        start = time.time()
    zoomMeetingInProgress = False

    def GetFirstChild(control):
        return control.GetFirstChildControl()

    def GetNextSibling(control):
        return control.GetNextSiblingControl()

    desktop = automation.GetRootControl()
    #window = automation.WindowControl(searchDepth=1, ClassName='ZPContentViewWndClass')
    #toolsMenu = window.WindowControl(searchDepth=3, ClassName='ZPControlPanelClass')
    #start = time.time()
    for control, depth in automation.WalkTree(desktop,
                                              getFirstChild=GetFirstChild,
                                              getNextSibling=GetNextSibling,
                                              includeTop=False,
                                              maxDepth=2):
        if debugWalkTree:
            print('DEBUG:' + str(depth) + ' ' * depth * 4 + str(control))
        if str(control).find("ZPContentViewWndClass") > 0:
            zoomMeetingInProgress = True
    return zoomMeetingInProgress
def main(directory: str, maxDepth: int = 0xFFFFFFFF):
    remain = {}
    texts = []
    absdir = os.path.abspath(directory)
    for (it, isDir), depth, remainCount in auto.WalkTree((absdir, True),
                                                         getChildren=listDir,
                                                         includeTop=True,
                                                         maxDepth=maxDepth):
        remain[depth] = remainCount
        prefix = ''.join('┃   ' if remain[i] else '    '
                         for i in range(1, depth))
        if depth > 0:
            if remain[depth] > 0:
                prefix += '┣━> ' if isDir else '┣━━ '
            else:
                prefix += '┗━> ' if isDir else '┗━━ '
        file = os.path.basename(it)
        texts.append(prefix)
        texts.append(file)
        texts.append('\n')
        auto.Logger.Write(prefix, writeToFile=False)
        auto.Logger.WriteLine(
            file,
            auto.ConsoleColor.Cyan if isDir else auto.ConsoleColor.Default,
            writeToFile=False)
    allText = ''.join(texts)
    auto.Logger.WriteLine(allText, printToStdout=False)
    ret = input(
        '\npress Y to save dir tree to clipboard, press other keys to exit\n')
    if ret.lower() == 'y':
        auto.SetClipboardText(allText)
def ExpandTreeItem(treeItem):
    for item, depth in automation.WalkTree(treeItem, getChildrenFunc = GetTreeItemChildren, includeTop = True, maxDepth = MaxExpandDepth):
        if isinstance(item, automation.TreeItemControl):  #or item.ControlType == automation.ControlType.TreeItemControl
            if PrintTree:
                automation.Logger.WriteLine(' ' * (depth * 4) + item.Name)
            if depth < MaxExpandDepth:  # and automation.ExpandCollapseState.Collapsed == item.CurrentExpandCollapseState():
                item.Expand(0)
            item.ScrollIntoView()
예제 #8
0
def end_meeting():
  automation.SendKeys('{Alt}q')
  time.sleep(1)

  window = automation.WindowControl(searchDepth=1, ClassName='zLeaveWndClass')
  for control, depth in automation.WalkTree(window, getFirstChild=GetFirstChild, getNextSibling=GetNextSibling, includeTop=False, maxDepth=2):
    if str(control).find("End Meeting for All") > 0:
      control.Click(simulateMove = False)
      exit(0)
예제 #9
0
    def print_tree(
        self,
        locator: Optional[Locator] = None,
        max_depth: int = 8,
        capture_image_folder: Optional[str] = None,
        log_as_warnings: bool = False,
    ) -> None:
        """Print Control element tree.

        Windows application structure can contain multilevel element
        structure. Understanding this structure is important for
        creating locators.

        This keyword can be used to output application element structure
        starting with the element defined by the `locator`.

        :param locator: string locator or Control element
        :param max_depth: maximum depth level (defaults to 8)
        :param encoding: defaults to "utf-8"
        :param capture_image_folder: if None images are not captured
        :param log_as_warnings: if set log messages are visible on the console
        """
        def GetFirstChild(ctrl: TreeNode) -> TreeNode:
            return ctrl.GetFirstChildControl()

        def GetNextSibling(ctrl: TreeNode) -> TreeNode:
            return ctrl.GetNextSiblingControl()

        index = 1
        target_elem = self.ctx.get_element(locator)
        image_folder = None
        if capture_image_folder:
            image_folder = Path(capture_image_folder).expanduser().resolve()
            image_folder.mkdir(parents=True, exist_ok=True)
        control_log = self.logger.warning if log_as_warnings else self.logger.info

        for control, depth in auto.WalkTree(
                target_elem.item,
                getFirstChild=GetFirstChild,
                getNextSibling=GetNextSibling,
                includeTop=True,
                maxDepth=max_depth,
        ):
            control_str = str(control)
            if image_folder:
                capture_filename = f"{control.ControlType}_{index}.png"
                img_path = str(image_folder / capture_filename)
                try:
                    control.CaptureToImage(img_path)
                except Exception as exc:  # pylint: disable=broad-except
                    self.logger.warning("Couldn't capture into %r due to: %s",
                                        img_path, exc)
                else:
                    control_str += f" [{capture_filename}]"
            control_log(" " * depth * 4 + control_str)
            index += 1
def WalkDesktop():
    def GetFirstChild(control):
        return control.GetFirstChildControl()

    def GetNextSibling(control):
        return control.GetNextSiblingControl()

    desktop = automation.GetRootControl()
    for control, depth in automation.WalkTree(desktop, getFirstChild=GetFirstChild, getNextSibling=GetNextSibling, includeTop=True, maxDepth=2):
        print(' ' * depth * 4 + str(control))
예제 #11
0
 def GetZoomStatus(self):
     for control, depth in automation.WalkTree(
             self.toolsMenu,
             getFirstChild=self.GetFirstChild,
             getNextSibling=self.GetNextSibling,
             includeTop=False,
             maxDepth=2):
         if str(control).find("currently muted") > 0:
             self.muted = True
         elif str(control).find("currently unmuted") > 0:
             self.muted = False
예제 #12
0
 def DetectZoomMeeting(self):
     for control, depth in automation.WalkTree(
             self.desktop,
             getFirstChild=self.GetFirstChild,
             getNextSibling=self.GetNextSibling,
             includeTop=False,
             maxDepth=2):
         if str(control).find("ZPContentViewWndClass") > 0:
             self.inMeeting = True
             return
     self.inMeeting = False
예제 #13
0
def GetPersonDetail():
    detailWindow = automation.WindowControl(searchDepth= 1, ClassName = 'TXGuiFoundation', SubName = '的资料')
    detailPane = detailWindow.PaneControl(Name = '资料')
    details = ''
    for control, depth in automation.WalkTree(detailPane, lambda c: c.GetChildren()):
        if control.ControlType == automation.ControlType.TextControl:
            details += control.Name
        elif control.ControlType == automation.ControlType.EditControl:
            details += control.CurrentValue() + '\n'
    details += '\n' * 2
    detailWindow.Click(0.95, 0.02)
    return details
예제 #14
0
 def ExpandTreeItem(self, treeItem: auto.TreeItemControl):
     lst = []
     for item, depth in auto.WalkTree(treeItem, getFirstChild=self.GetFirstChild, getNextSibling=self.GetNextSibling, includeTop=True, maxDepth=1):
         # or item.ControlType == auto.ControlType.TreeItemControl
         if isinstance(item, auto.TreeItemControl):
             print(item.Name)
             if item.Name != 'Key Figures' and item.Name != 'Open Order by Status KFs SchLn':
                 arr = item.Name.split(']')
                 field = BWField(arr[0][1:].strip(), arr[1].strip(),self.CurrentQueryName)
                 print(field)
                 self.db.insert_one(field.__dict__)
                 self.dbAllinOne.insert_one(field.__dict__)
def WalkDir():
    def GetDirChildren(dir):
        if os.path.isdir(dir):
            subdirs = []
            files = []
            for it in os.listdir(dir):
                absPath = os.path.join(dir, it)
                if os.path.isdir(absPath):
                    subdirs.append(absPath)
                else:
                    files.append(absPath)
            return subdirs + files

    for it, depth, remainCount in automation.WalkTree(r'c:\Program Files\Internet Explorer', getChildrenFunc=GetDirChildren, includeTop=True):
        print(' ' * depth * 4 + it)
def WalkPermutations(uniqueItems):
    def NextPermutations(aTuple):
        left, permutation = aTuple
        ret = []
        for i, item in enumerate(left):
            nextLeft = left[:]
            del nextLeft[i]
            nextPermutation = permutation + [item]
            ret.append((nextLeft, nextPermutation))
        return ret

    n = len(uniqueItems)
    count = 0
    for (left, permutation), depth, remain in automation.WalkTree((uniqueItems, []), NextPermutations, yieldCondition=lambda c, d: d == n):
        count += 1
        print(count, permutation)
예제 #17
0
def main():
    subprocess.Popen('mmc.exe devmgmt.msc')
    mmcWindow = automation.WindowControl(searchDepth=1,
                                         ClassName='MMCMainFrame')
    tree = automation.TreeControl(searchFromControl=mmcWindow)
    for item, depth in automation.WalkTree(
            tree, getChildrenFunc=lambda c: c.GetChildren(), includeTop=True):
        if isinstance(
                item, automation.TreeItemControl
        ):  #or item.ControlType == automation.ControlType.TreeItemControl
            item.Select()
            if automation.ExpandCollapseState.Collapsed == item.CurrentExpandCollapseState(
            ):
                item.Expand(0)
            automation.Logger.WriteLine(' ' * (depth - 1) * 4 + item.Name,
                                        automation.ConsoleColor.Green)
            time.sleep(0.1)
예제 #18
0
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)
예제 #19
0
def GetZoomStatus():
    statusMute = "unknown"
    statusVideo = "unknown"
    statusShare = "unknown"
    statusRecord = "unknown"

    def GetFirstChild(control):
        return control.GetFirstChildControl()

    def GetNextSibling(control):
        return control.GetNextSiblingControl()

    desktop = automation.GetRootControl()
    window = automation.WindowControl(searchDepth=1,
                                      ClassName='ZPContentViewWndClass')
    toolsMenu = window.WindowControl(searchDepth=3,
                                     ClassName='ZPControlPanelClass')

    if debug:
        print("desktop=" + str(desktop))
        print("window=" + str(window))
        print("toolsMenu=" + str(toolsMenu))

    for control, depth in automation.WalkTree(toolsMenu,
                                              getFirstChild=GetFirstChild,
                                              getNextSibling=GetNextSibling,
                                              includeTop=False,
                                              maxDepth=2):
        if debugWalkTree:
            print(str(depth) + ' ' * depth * 4 + str(control))
        if str(control).find("currently muted") > 0:
            statusMute = "muted"
        elif str(control).find("currently unmuted") > 0:
            statusMute = "unmuted"

        elif str(control).find("start my video") > 0:
            statusVideo = "stopped"
        elif str(control).find("stop my video") > 0:
            statusVideo = "started"

        elif str(control).find("Share Screen") > 0:
            statusShare = "stopped"
        elif str(control).find("Pause Share") > 0:
            statusShare = "started"
        elif str(control).find("Resume Share") > 0:
            statusShare = "paused"

# The maxDepth needs to be increased if you want to add recording status.  However, it doubles the processing time.
#       elif  str(control).find("Name: Record")  > 0 :
#           statusRecord = "stopped"
#       elif  str(control).find("Pause/Stop Recording")  > 0 :
#           statusRecord = "started"
#       elif  str(control).find("Resume Share")  > 0 :
#           statusRecord = "paused"

    if debug:
        stop = time.time()
        print("Elapsed Time:", stop - start)
    statusZoom = "open"

    statusJSON = {
        "statusZoom": statusZoom,
        "statusMute": statusMute,
        "statusVideo": statusVideo,
        "statusShare": statusShare
    }
    y = json.dumps(statusJSON)
    print(y)
def AnalyzeUI(sampleRate=90000,
              payload=96,
              beginNo=0,
              maxPackets=0xFFFFFFFF,
              showLost=False):
    """Wireshark version must >= 2.0"""
    wireSharkWindow = automation.WindowControl(searchDepth=1,
                                               ClassName='Qt5QWindowIcon')
    if wireSharkWindow.Exists(0, 0):
        wireSharkWindow.SetActive()
    else:
        automation.Logger.WriteLine('can not find wireshark',
                                    automation.ConsoleColor.Yellow)
        return
    tree = wireSharkWindow.TreeControl(searchDepth=4, SubName='Packet list')
    left, top, right, bottom = tree.BoundingRectangle
    tree.Click(10, 30)
    automation.SendKeys('{Home}{Ctrl}{Alt}4')
    time.sleep(0.5)
    tree.Click(10, 30)
    headers = []
    headerFunctionDict = {
        'No': int,
        'Time': float,
        'Source': str,
        'Destination': str,
        'Protocol': str,
        'Length': int,
        'Info': str,
    }
    index = 0
    payloadStr = 'PT=DynamicRTP-Type-' + str(payload)
    packets = []
    for item, depth in automation.WalkTree(
            tree,
            getFirstChildFunc=lambda c: c.GetFirstChildControl(),
            getNextSiblingFunc=lambda c: c.GetNextSiblingControl()):
        if isinstance(item, automation.HeaderControl):
            headers.append(item.Name.rstrip('.'))
        elif isinstance(item, automation.TreeItemControl):
            if index == 0:
                if len(packets) >= maxPackets:
                    break
                packet = PacketInfo()
            name = item.Name
            packet.__dict__[headers[index]] = headerFunctionDict[
                headers[index]](name)
            if headers[index] == 'Info':
                findPayload = True
                while findPayload:
                    ptIndex = name.find('PT=DynamicRTP-Type', 1)
                    if ptIndex > 0:
                        info = name[:ptIndex]
                        name = name[ptIndex:]
                        findPayload = True
                    else:
                        info = name
                        findPayload = False
                    packet.Info = info
                    if info.find(payloadStr) >= 0:
                        packet = copy.copy(packet)
                        startIndex = info.find('Seq=')
                        if startIndex > 0:
                            endIndex = info.find(' ', startIndex)
                            packet.Seq = int(info[startIndex +
                                                  4:endIndex].rstrip(','))
                        startIndex = info.find('Time=', startIndex)
                        if startIndex > 0:
                            endIndex = startIndex + 5 + 1
                            while str.isdigit(info[startIndex + 5:endIndex]
                                              ) and endIndex <= len(info):
                                packet.TimeStamp = int(info[startIndex +
                                                            5:endIndex])
                                endIndex += 1
                            if packet.No >= beginNo:
                                packets.append(packet)
                                automation.Logger.WriteLine(
                                    'No: {0[No]:<10}, Time: {0[Time]:<10}, Protocol: {0[Protocol]:<6}, Length: {0[Length]:<6}, Info: {0[Info]:<10},'
                                    .format(packet.__dict__))
            index = (index + 1) % len(headers)
            if item.BoundingRectangle[3] >= bottom:
                automation.SendKeys('{PageDown}')
                time.sleep(0.1)
    AnalyzePackets(packets, sampleRate, showLost)
예제 #21
0
def Analyze(sampleRate=90000,
            beginNo=0,
            maxPackets=0xFFFFFFFF,
            calculateLost=False):
    wireSharkWindow = automation.WindowControl(searchDepth=1,
                                               ClassName='Qt5QWindowIcon')
    if wireSharkWindow.Exists(0, 0):
        wireSharkWindow.SetActive()
    else:
        automation.Logger.WriteLine('can not find wireshark',
                                    automation.ConsoleColor.Yellow)
        return
    tree = automation.TreeControl(searchFromControl=wireSharkWindow,
                                  searchDepth=4,
                                  SubName='Packet list')
    left, top, right, bottom = tree.BoundingRectangle
    tree.Click(10, 30)
    automation.SendKeys('{Home}{Ctrl}{Alt}4')
    time.sleep(0.5)
    tree.Click(10, 30)
    headers = []
    headerFunctionDict = {
        'No': int,
        'Time': float,
        'Source': str,
        'Destination': str,
        'Protocol': str,
        'Length': int,
        'Info': str,
    }
    index = 0
    packets = []
    for item, depth in automation.WalkTree(
            tree,
            getFirstChildFunc=lambda c: c.GetFirstChildControl(),
            getNextSiblingFunc=lambda c: c.GetNextSiblingControl()):
        if isinstance(item, automation.HeaderControl):
            headers.append(item.Name.rstrip('.'))
        elif isinstance(item, automation.TreeItemControl):
            if index == 0:
                if len(packets) >= maxPackets:
                    break
                packet = PacketInfo()
            name = item.Name
            packet.__dict__[headers[index]] = headerFunctionDict[
                headers[index]](name)
            if headers[index] == 'Info':
                startIndex = name.find('Seq=')
                if startIndex > 0:
                    endIndex = name.find(' ', startIndex)
                    packet.Seq = int(name[startIndex + 4:endIndex].rstrip(','))
                startIndex = name.find('Time=')
                if startIndex > 0:
                    endIndex = name.find(' ', startIndex)
                    packet.TimeStamp = int(name[startIndex +
                                                5:endIndex].rstrip(','))
                    if packet.No >= beginNo:
                        packets.append(packet)
                        automation.Logger.WriteLine(
                            'No: {0[No]:<10}, Time: {0[Time]:<10}, Protocol: {0[Protocol]:<6}, Length: {0[Length]:<6}, Info: {0[Info]:<10},'
                            .format(packet.__dict__))
            index = (index + 1) % len(headers)
            if item.BoundingRectangle[3] >= bottom:
                automation.SendKeys('{PageDown}')
                time.sleep(0.1)

    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)
        lastTimeStamp = p.TimeStamp

    lastTimeStamp = -1
    lastTime = -1
    totalDiff = 0
    frameCount = 0
    for p in framePackets:
        if lastTimeStamp < 0:
            automation.Logger.WriteLine(
                'No: {0[No]:<8}, Time: {0[Time]:<10}, Protocol: {0[Protocol]}, Length: {0[Length]:<6}, TimeStamp: {0[TimeStamp]:<15}'
                .format(p.__dict__))
        else:
            diffTimeStamp = p.TimeStamp - lastTimeStamp
            frameCount += 1
            totalDiff += diffTimeStamp
            sumTime = p.Time - framePackets[0].Time
            sumTimeFromTimeStamp = (p.TimeStamp -
                                    framePackets[0].TimeStamp) / sampleRate
            automation.Logger.WriteLine(
                'No: {0[No]:<8}, Time: {0[Time]:<10}, Protocol: {0[Protocol]}, Length: {0[Length]:<6}, TimeStamp: {0[TimeStamp]:<15}, 帧时间戳差值: {1:<6}, 帧实际时间差值: {2:<10.6f}, 实际接收时间: {3:<10.6f}, 时间戳时间: {4:<10.6f}, 提前时间:{5:<10.6f}'
                .format(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
        if calculateLost:
            automation.Logger.WriteLine(
                '\n包总数: {0}, 帧数: {1}, 实际帧率:{2:.2f}, 平均时间戳: {3}, 总时间: {4:.6f}, 时间戳总时间: {5:.6f}, 丢包数: {6}({7:.2f}%), 丢包序号: {8}'
                .format(len(packets), frameCount, frameCount / realTime,
                        averageDiff, realTime, totalTimeFromTimeStamp,
                        len(lostSeqs),
                        len(lostSeqs) / seqCount, lostSeqs))
        else:
            automation.Logger.WriteLine(
                '\n包总数: {0}, 帧数: {1}, 实际帧率:{2:.2f}, 平均时间戳: {3}, 总时间: {4:.6f}, 时间戳总时间: {5:.6f}'
                .format(len(packets), frameCount, frameCount / realTime,
                        averageDiff, realTime, totalTimeFromTimeStamp))
예제 #22
0
def GetZoomStatus():
  global debug
  global zoomToolbarOpen
  global zoomMeetingOpen
  global toggleMute
  global toggleVideo
  global toggleShare
  statusMute   = "unknown"
  statusVideo  = "unknown"
  statusShare  = "unknown"
  statusRecord = "unknown"

  desktop   = automation.GetRootControl()
  if zoomToolbarOpen == True:
    window    = automation.WindowControl(searchDepth=1, ClassName='ZPFloatToolbarClass')
    toolsMenu = window
  else:
    window    = automation.WindowControl(searchDepth=1, ClassName='ZPContentViewWndClass')
    toolsMenu = window.WindowControl(searchDepth=3, ClassName='ZPControlPanelClass')
  if debug == True:
    print ("desktop="+str(desktop))
    print ("window="+str(window))
    print ("toolsMenu="+str(toolsMenu))
  for control, depth in automation.WalkTree(toolsMenu, getFirstChild=GetFirstChild, getNextSibling=GetNextSibling, includeTop=False, maxDepth=2):
    if debug == True:
      print(str(depth) + ' ' * depth * 4 + str(control))
    if str(control).find("currently muted") > 0:
      statusMute = "muted"
      if toggleMute == True:
        automation.SendKeys('{Alt}a')
        statusMute = "unmuted"
    elif str(control).find("currently unmuted") > 0:
      statusMute = "unmuted"
      if toggleMute == True:
        automation.SendKeys('{Alt}a')
        statusMute = "muted"
    elif str(control).find("start my video") > 0:
      statusVideo = "stopped"
      if toggleVideo == True:
        automation.SendKeys('{Alt}v')
        statusVideo = "started"
    elif str(control).find("stop my video") > 0:
      statusVideo = "started"
      if toggleVideo == True:
        automation.SendKeys('{Alt}v')
        statusVideo = "stopped"
    elif str(control).find("Share Screen") > 0:
      statusShare = "stopped"
      if toggleShare == True:
        automation.SendKeys('{Alt}s')
        statusShare = "started"
    elif str(control).find("Stop Share") > 0:
      statusShare = "started"
      if toggleShare == True:
        automation.SendKeys('{Alt}s')
        statusShare = "stopped"
    elif str(control).find("Resume Share") > 0:
      statusShare = "disabled"
    # Toolbar
    elif str(control).find("Start Video") > 0:
      statusVideo = "stopped"
      if toggleVideo == True:
        automation.SendKeys('{Alt}v')
        statusVideo = "started"
    elif str(control).find("Stop Video") > 0:
      statusVideo = "started"
      if toggleVideo == True:
        automation.SendKeys('{Alt}v')
        statusVideo = "stopped"

 # The maxDepth needs to be increased if you want to add recording status.  However, it doubles the processing time.
 #       elif  str(control).find("Name: Record") > 0:
 #           statusRecord = "stopped"
 #       elif  str(control).find("Pause/Stop Recording") > 0:
 #           statusRecord = "started"
 #       elif  str(control).find("Resume Share") > 0:
 #           statusRecord = "paused"


  if debug == True:
    stop = time.time()
    print("Elapsed Time:", stop-start)

  statusZoom = "call"
  status = "zoomStatus:"+statusZoom+",zoomMute:"+statusMute+",zoomVideo:"+statusVideo+",zoomShare:"+statusShare
  print (status)