From 4d391c7a9a6c96069c634b9d7af1c5e622eff63d Mon Sep 17 00:00:00 2001 From: suti7yk5032 Date: Fri, 7 Jun 2024 22:29:00 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=86=E3=82=B9=E3=83=88=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- temp/kill.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 temp/kill.py diff --git a/temp/kill.py b/temp/kill.py new file mode 100644 index 0000000..2c68cbf --- /dev/null +++ b/temp/kill.py @@ -0,0 +1,22 @@ +import wmi +import asyncio + +async def watcher(): + c=wmi.WMI() + cre_process_watcher=c.Win32_Process.watch_for("creation") + del_process_watcher=c.Win32_Process.watch_for("deletion") + + while True: + new_cre_process=cre_process_watcher() + new_del_process=del_process_watcher() + print(new_cre_process.Caption+" has been created") + print(new_del_process.Caption+" has been deleted ") + +async def main(): + kill_task = asyncio.TaskGroup(watcher()) + print('hello world') + await asyncio.sleep(1) + print('1sec') + await kill_task + +asyncio.run(main())