-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloseapp.py
More file actions
41 lines (30 loc) · 957 Bytes
/
closeapp.py
File metadata and controls
41 lines (30 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import subprocess
from difflib import get_close_matches as find
from jiya import speak
from os import system
program=[]
progid=[]
progdict={}
cmd='powershell "gps |where mainwindowtitle |select Description'
cmd1='powershell "gps |where mainwindowtitle |select id'
proc=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE)
proc1=subprocess.Popen(cmd1,shell=True,stdout=subprocess.PIPE)
for line in proc.stdout:
st=str(line.decode().rstrip())
program.append(st)
for line in proc1.stdout:
st=str(line.decode().rstrip())
progid.append(st)
for i in range(0,len(progid)):
progdict[program[i]]=progid[i]
def close(c):
global program,progid,progdict
q=find(c,program)
if q==[]:
speak("app is not found to close")
else:
for key,value in progdict.items():
if key==q[0]:
speak(f"{key} is closing")
system("taskkill /im "+ str(value))
close("google chrome")