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())