代码拉取完成,页面将自动刷新
同步操作将从 yinkaisheng/PythonUIAutomation4Windows 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!python3
# -*- coding: utf-8 -*-
import os
import time
import automation
def CaptureControl(c, path, up = False):
if c.CaptureToImage(path):
os.popen(path)
automation.Logger.WriteLine('capture image: ' + path)
else:
automation.Logger.WriteLine('capture failed', automation.ConsoleColor.Yellow)
if up:
r = automation.GetRootControl()
depth = 0
name, ext = os.path.splitext(path)
while True:
c = c.GetParentControl()
if not c or automation.ControlsAreSame(c, r):
break
depth += 1
savePath = name + '_p' * depth + ext
if c.CaptureToImage(savePath):
automation.Logger.WriteLine('capture image: ' + savePath)
def main(args):
if args.time > 0:
time.sleep(args.time)
start = time.clock()
if args.active:
c = automation.GetForegroundControl()
elif args.cursor or args.up:
c = automation.ControlFromCursor()
elif args.fullscreen:
c = automation.GetRootControl()
CaptureControl(c, args.path, args.up)
automation.Logger.WriteLine('cost time: {:.3f} s'.format(time.clock() - start))
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--fullscreen', action='store_true', default = True, help = 'capture full screen')
parser.add_argument('-a', '--active', action='store_true', help = 'capture active window')
parser.add_argument('-c', '--cursor', action='store_true', help = 'capture control under cursor')
parser.add_argument('-u', '--up', action='store_true', help = 'capture control under cursor and up to its top window')
parser.add_argument('-p', '--path', type = str, default = 'capture.png', help = 'save path')
parser.add_argument('-t', '--time', type = int, default = 0, help = 'delay time')
args = parser.parse_args()
#automation.Logger.WriteLine(str(args))
main(args)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。