Compare commits
2 commits
bdaf1ac0d8
...
4d391c7a9a
Author | SHA1 | Date | |
---|---|---|---|
4d391c7a9a | |||
3f1611dde1 |
2 changed files with 44 additions and 0 deletions
|
@ -4,6 +4,9 @@ import json
|
|||
import customtkinter
|
||||
from winotify import Notification, audio
|
||||
import keyboard
|
||||
import wmi
|
||||
import subprocess
|
||||
import asyncio
|
||||
|
||||
class App(customtkinter.CTk):
|
||||
def __init__(self):
|
||||
|
@ -17,6 +20,7 @@ class App(customtkinter.CTk):
|
|||
self.restore_button = customtkinter.CTkButton(self.frame, text='認証ウィンドウを再表示', command=self.handler_close, width=240)
|
||||
self.restore_button.grid(row=0, column=0)
|
||||
|
||||
asyncio.run(self.task_watcher_run())
|
||||
self.block_key()
|
||||
lock = Lock()
|
||||
|
||||
|
@ -40,6 +44,24 @@ class App(customtkinter.CTk):
|
|||
success.set_audio(audio.Default, loop=False)
|
||||
success.show()
|
||||
|
||||
async def task_watcher_run(self):
|
||||
taskmgr_killer = asyncio.create_task(self.task_watcher())
|
||||
|
||||
async def task_watcher(self):
|
||||
c=wmi.WMI()
|
||||
cre_process_watcher=c.Win32_Process.watch_for("creation")
|
||||
del_process_watcher=c.Win32_Process.watch_for("deletion")
|
||||
|
||||
self.i = 1
|
||||
|
||||
while self.i == 1:
|
||||
new_cre_process=cre_process_watcher()
|
||||
new_del_process=del_process_watcher()
|
||||
print(new_cre_process.Caption+" has been created")
|
||||
if new_cre_process.Caption == "Taskmgr.exe":
|
||||
taskmgr_kill = subprocess.run(['taskkill', '/im', 'Taskmgr.exe'])
|
||||
print(new_del_process.Caption+" has been deleted ")
|
||||
|
||||
def handler_close(self):
|
||||
pass
|
||||
|
||||
|
|
22
temp/kill.py
Normal file
22
temp/kill.py
Normal file
|
@ -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())
|
Loading…
Reference in a new issue