-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwinApps.py
46 lines (31 loc) · 1.13 KB
/
winApps.py
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
41
42
43
44
45
46
# So since winapps is so damn shitty
# imma do this myself ;_;
# gosh I hate my life
from pathlib import Path
import os
from difflib import SequenceMatcher
class winapps:
WinApps = {}
@classmethod
def getInstalledApps(cls):
mypath = f"{os.getenv('APPDATA')}/Microsoft/Windows/Start Menu/Programs"
for r, d, f in os.walk(mypath):
for file in f:
filePath = os.path.join(r, file)
cls.WinApps[filePath.split('\\')[-1].split('.')[0]] = filePath.replace('\\', '/')
return cls.WinApps
@classmethod
def searchForApp(cls, appName):
winapps.getInstalledApps()
highest = None
highesRatio = 0
for app in winapps.WinApps.keys():
ratio = SequenceMatcher(None, appName, app).ratio()
if ratio > highesRatio:
highesRatio = ratio
highest = app
return winapps.WinApps[highest]
@classmethod
def launch(cls, app):
os.chdir('/'.join(app.split('/')[0:-1]))
os.system(app.split('/')[-1])