[英]How can I find where a windows program is installed using only its full name? (And the name of his executable)
我正在創建一個程序來識別我的聲音:開放*程序名稱*然后打開程序。 我有一個腳本來解密所有已安裝程序的名稱,但我不知道如何獲取我想要的信息。
import speech_recognition as sr
r = sr.Recognizer()
with sr.Microphone() as s:
r.adjust_for_ambient_noise(s)
while True:
audio = r.listen(s)
try:
speech = r.recognize_google(audio, language = 'en-US')
speech = str(speech)
speech = speech.lower()
print('Você disse: ' + speech)
if 'bash' in speech:
#Should open the GitBash
if 'mozilla' in speech:
#Should open the Mozilla
except:
pass
我希望該計划能夠開啟該計划
如果您知道如何從命令行打開程序,我們可以使用OS程序包來運行這些命令。 希望這可以幫助!
import os
os.system("COMMAND TO OPEN PROGRAM FROM COMMAND LINE")
我們需要一種方法來列出特定目錄中的所有文件(本例中為程序目錄)以下代碼可幫助我們執行此操作。
import os
def listAllFiles(path):
if os.path.isfile(path):
return [ path ]
else:
files = [ ]
for filename in os.listdir(path):
files += listAllFiles(path + "/" + filename)
return files
print(listAllFiles("Documents"))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.