chore(models): 优化MAA关闭方法

This commit is contained in:
DLmaster
2025-02-12 22:15:17 +08:00
parent 7dc057e30f
commit d45da439bd
3 changed files with 16 additions and 20 deletions

View File

@@ -177,6 +177,17 @@ class _SystemHandler:
win32gui.EnumWindows(callback, window_info)
return window_info
def kill_process(self, path: Path) -> None:
"""根据路径中止进程"""
for pid in self.search_pids(path):
killprocess = subprocess.Popen(
f"taskkill /F /T /PID {pid}",
shell=True,
creationflags=subprocess.CREATE_NO_WINDOW,
)
killprocess.wait()
def search_pids(path: Path) -> list:
"""根据路径查找进程PID"""