获取windows的cmd命令窗口输出信息
作者:互联网
import time from uiautomation import DocumentControl import clipboard # 获取CMD窗口 window = DocumentControl(searchDepth=3, Name='Text Area') # 测试在CMD里面删除某个文件 # window.SendKeys('del /p test.txt') window.SendKeys('python selenium_base_demo.py') window.SendKeys('{Enter}') time.sleep(3) # Ctrl A / C 全选复制 window.SendKeys('{Ctrl}A') window.SendKeys('{Ctrl}C') # 获取剪切板里面的复制内容 result = clipboard.paste() print(result) # 判断复制内容是否是以特定内容结尾或者特定字符 # ''.startswith() if 'DevTools' in result: # 输入内容 window.SendKeys('n') window.SendKeys('{Enter}') window.Close() # 执行完成 print('finished') else: print('No such value,not complete')
标签:窗口,Ctrl,windows,cmd,window,result,print,import,SendKeys 来源: https://www.cnblogs.com/yunlongaimeng/p/15459335.html