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))
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 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 threadFunc(num: int): count = 0 end = auto.ProcessTime() + 2 while auto.ProcessTime() < end: count += 1 if not auto.SetClipboardText('{}'.format(random.randint(0, 10000))): print(num, 'failed') print(num, 'count', count)
def main(): formats = auto.GetClipboardFormats() for k, v in formats.items(): auto.Logger.WriteLineColorfully( 'Clipboard has format <Color=Cyan>{}, {}</Color>'.format(k, v)) if k == auto.ClipboardFormat.CF_UNICODETEXT: auto.Logger.WriteLineColorfully( ' Text in clipboard is: <Color=Cyan>{}</Color>'.format( auto.GetClipboardText())) elif k == auto.ClipboardFormat.CF_HTML: htmlText = auto.GetClipboardHtml() auto.Logger.WriteLineColorfully( ' Html text in clipboard is: <Color=Cyan>{}</Color>'.format( htmlText)) elif k == auto.ClipboardFormat.CF_BITMAP: auto.Logger.WriteLineColorfully( ' Bitmap clipboard is: <Color=Cyan>{}</Color>'.format( auto.GetClipboardBitmap())) auto.InputColorfully( 'paused, press Enter to test <Color=Cyan>SetClipboardText</Color>', auto.ConsoleColor.Green) auto.SetClipboardText('Hello World') auto.InputColorfully( '<Color=Yellow>You can paste it in Office Word now.</Color>\npaused, press Enter to test <Color=Cyan>SetClipboardHtml</Color>' ) auto.SetClipboardHtml( '<h1>Title</h1><br><h3>Hello</h3><br><p>test html</p><br>'), auto.InputColorfully( '<Color=Yellow>You can paste it in Office Word now.</Color>\npaused, press Enter to test <Color=Cyan>SetClipboardBitmap</Color>' ) c = auto.ControlFromCursor() with c.ToBitmap() as bmp: auto.SetClipboardBitmap(bmp) auto.InputColorfully( '<Color=Yellow>You can paste it in Office Word now.</Color>\npaused, press Enter to <Color=Cyan>exit</Color>' )
def set_clipboard_text(self, value): try: auto.SetClipboardText(value) logger.info("{}_设置成剪切板内容成功".format(value)) except: logger.exception("_{}_设置成剪切板内容失败".format(value))