Форум сайта python.su
Код определяет запущен ли в данный момент указанный процесс:
import psutil def check_python_program(program_name): for proc in psutil.process_iter(): try: if proc.name() == program_name: return True except (psutil.NoSuchProcess, psutil.AccessDenied, psutil.ZombieProcess): pass return False if check_python_program("msedge.exe"): print("Программа запущена.") else: print("Программа не запущена.")
Офлайн
This code is a simple and efficient way to check if a process, such as msedge.exe, is running using the psutil library. However, as noted, Microsoft Edge often runs in the background (e.g. due to notifications or updates), making it more difficult to determine the usage of the active browser window. Sprunki Pyramixed
Офлайн