From 0b03527e338c22c24b31566370bd36e705a4bfaf Mon Sep 17 00:00:00 2001 From: suti7yk5032 Date: Sat, 8 Jun 2024 09:33:54 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=AC=E3=82=B8=E3=82=B9=E3=83=88=E3=83=AA?= =?UTF-8?q?=E3=81=A7=E3=82=BF=E3=82=B9=E3=82=AF=E3=83=9E=E3=83=8D=E3=83=BC?= =?UTF-8?q?=E3=82=B8=E3=83=A3=E3=83=BC=E3=81=AE=E5=AE=9F=E8=A1=8C=E3=82=92?= =?UTF-8?q?=E3=83=96=E3=83=AD=E3=83=83=E3=82=AF=E3=81=99=E3=82=8B=E3=82=88?= =?UTF-8?q?=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dislocker_client.py | 33 +++++++++------------------------ 1 file changed, 9 insertions(+), 24 deletions(-) diff --git a/dislocker_client.py b/dislocker_client.py index 1e6d213..b8a65cc 100644 --- a/dislocker_client.py +++ b/dislocker_client.py @@ -4,9 +4,7 @@ import json import customtkinter from winotify import Notification, audio import keyboard -import wmi import subprocess -import asyncio class App(customtkinter.CTk): def __init__(self): @@ -20,11 +18,12 @@ 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_taskmgr self.block_key() lock = Lock() def exit(self): + self.unlock_taskmgr() self.toast() self.destroy() @@ -33,6 +32,12 @@ class App(customtkinter.CTk): for i in block_keys: keyboard.block_key(i) + def block_taskmgr(self): + subprocess.run(['reg', 'add', 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', '/v', 'DisableTaskMgr', '/t', 'REG_DWORD', '/d', '1']) + + def unlock_taskmgr(self): + subprocess.run(['reg', 'delete', 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System', '/v', 'DisableTaskMgr', '/f']) + def toast(self): resource_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "resource") success = Notification( @@ -44,24 +49,6 @@ 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 @@ -120,9 +107,6 @@ class Lock(customtkinter.CTkToplevel): def exit(self): self.destroy() - - - config_dir_path = "./config/" db_config_path = config_dir_path + "db.json" @@ -147,3 +131,4 @@ if __name__ == '__main__': app = App() app.protocol("WM_DELETE_WINDOW", app.handler_close) app.mainloop() +