代码拉取完成,页面将自动刷新
同步操作将从 yinkaisheng/PythonUIAutomation4Windows 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!python3
# -*- coding: utf-8 -*-
import os
import sys
import time
import subprocess
import automation
def CollapseTreeItem(treeItem):
if not isinstance(treeItem, automation.TreeItemControl):
return False
children = treeItem.GetChildren()
if children:
for it in children:
CollapseTreeItem(it)
treeItem.Collapse(0)
return True
return False
def main():
treeItem = automation.ControlFromCursor()
CollapseTreeItem(treeItem)
def HotKeyFunc(stopEvent):
scriptName = os.path.basename(__file__)
cmd = r'py.exe {} main {}'.format(scriptName, ' '.join(sys.argv[1:]))
automation.Logger.WriteLine('call ' + cmd)
p = subprocess.Popen(cmd)
while True:
if None != p.poll():
break
if stopEvent.is_set():
childProcess = []
for pid, pname in automation.Win32API.EnumProcess():
ppid = automation.Win32API.GetParentProcessId(pid)
if ppid == p.pid or pid == p.pid:
cmd = automation.Win32API.GetProcessCommandLine(pid)
childProcess.append((pid, pname, cmd))
for pid, pname, cmd in childProcess:
automation.Logger.WriteLine('kill process: {}, {}, "{}"'.format(pid, pname, cmd), automation.ConsoleColor.Yellow)
automation.Win32API.TerminateProcess(pid)
break
stopEvent.wait(1)
automation.Logger.WriteLine('HotKeyFunc exit')
if __name__ == '__main__':
if 'main' in sys.argv[1:]:
main()
else:
automation.Logger.WriteLine('move mouse to a tree control and press Ctrl+3', automation.ConsoleColor.Green)
automation.RunWithHotKey({(automation.ModifierKey.MOD_CONTROL, automation.Keys.VK_3) : HotKeyFunc}, (automation.ModifierKey.MOD_CONTROL, automation.Keys.VK_4))
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。