23 lines
591 B
Python
23 lines
591 B
Python
|
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())
|