Last active
September 25, 2018 07:44
-
-
Save Unison1/3eb7409199ee35e9450107bca27b2be4 to your computer and use it in GitHub Desktop.
Task list on Python for Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import sys | |
from subprocess import Popen, PIPE #Для работы с командной строкой Windows. | |
class ExplorerProsess(): | |
def case(self): | |
print("Процессы какой порграммы вывести:") | |
p = input() | |
if p.lower().endswith('.exe'): | |
print('=========================================================') | |
print(*[line.decode('cp866', 'ignore') for line in Popen("tasklist /FI \"IMAGENAME eq " + p + " \" /NH", stdout=PIPE).stdout.readlines()]) | |
else: | |
print('=========================================================') | |
print('Это не exe файл программы!') | |
time.sleep(0.2) | |
def full(self): | |
print(*[line.decode('cp866', 'ignore') for line in Popen("tasklist", stdout=PIPE).stdout.readlines()]) | |
time.sleep(0.2) | |
def kill(self): | |
print("Процессы какой порграммы завершаем:") | |
p = input() | |
if p.lower().endswith('.exe'): | |
print('=========================================================') | |
subprocess.Popen("taskkill /f /im " + p) | |
else: | |
print('=========================================================') | |
print('Это не exe файл программы!') | |
time.sleep(0.2) | |
def main(): | |
ep = ExplorerProsess() | |
print('=========================================================') | |
print("1. Вывемсти все процессы.") | |
print("2. Процессы какой порграммы вывести.") | |
print("3. Процессы какой порграммы завершаем.") | |
print("4. Выход.") | |
print('=========================================================') | |
time.sleep(0.2) | |
print('Выбор:') | |
r = input() | |
if r == '1': | |
ep.full() | |
elif r == '2': | |
ep.case() | |
elif r == '3': | |
ep.kill() | |
elif r == '4': | |
sys.exit() | |
else: | |
print('Такой команды нет!') | |
return main() | |
print('=========================================================') | |
if __name__=='__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment