1 В избранное 0 Ответвления 0

OSCHINA-MIRROR/yinkaisheng-PythonUIAutomation4Windows

Присоединиться к Gitlife
Откройте для себя и примите участие в публичных проектах с открытым исходным кодом с участием более 10 миллионов разработчиков. Приватные репозитории также полностью бесплатны :)
Присоединиться бесплатно
Клонировать/Скачать
collapse_tree_item_under_cursor.py 1.9 КБ
Копировать Редактировать Web IDE Исходные данные Просмотреть построчно История
yinkaisheng@foxmail.com Отправлено 02.11.2016 05:18 2dbff4a
#!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))

Опубликовать ( 0 )

Вы можете оставить комментарий после Вход в систему

1
https://api.gitlife.ru/oschina-mirror/yinkaisheng-PythonUIAutomation4Windows.git
git@api.gitlife.ru:oschina-mirror/yinkaisheng-PythonUIAutomation4Windows.git
oschina-mirror
yinkaisheng-PythonUIAutomation4Windows
yinkaisheng-PythonUIAutomation4Windows
master