windows 我试图让我自己的编码个人助理为我打开一个应用程序,但我不能弄清楚[关闭]

eyh26e7m  于 2023-04-22  发布在  Windows
关注(0)|答案(1)|浏览(80)

**已关闭。**此问题需要debugging details。当前不接受答案。

编辑问题以包括desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem。这将有助于其他人回答问题。
昨天关门了。
Improve this question
本质上,我正在创建我自己的“贾维斯”从铁人,或像谷歌助手或Alexa的个性化版本,但围绕我做什么,所以它可以帮助我定向.我希望能够给予它一个命令,如“打开Opera浏览器”或“打开Minecraft”或“打开Spotify”,它会打开说应用程序.然而,我尝试过的一切都没有结果。我对Python不是很有经验,但如果可能的话,我想让它工作。
我用的是Windows。
我试过这样的事情;

elif 'open minecraft' in command:
    pyttsx3.speak("Opening Minecraft")
    print(".")
    print(".")
    os.system("MinecraftLauncher.exe")

或者使用“AppOpener”软件包,但我在网上找到的两个选项似乎都不起作用。我可能完全错了,真的需要一些帮助。

gopyfrb3

gopyfrb31#

我能想到两种方法。
使用硬链接到exe:

pyttsx3.speak("Opening chrome")
print(".")
print(".")
os.system("path\to\the\exe\chrome.exe")

使用函数startfile
os.startfile(path[, operation][, arguments][, cwd][, show_cmd])
当操作未指定或“打开”时,其作用类似于在Windows资源管理器中双击文件,或将文件名作为交互式命令shell中的start命令的参数:用与其扩展名相关联的任何应用程序(如果有的话)打开该文件。
示例:

pyttsx3.speak("Opening chrome")
print(".")
print(".")
os.startfile("chrome")
# Other examples can be:
'''
os.startfile("msedge")
os.startfile("calc")
os.startfile("notepad")
os.startfile("cmd")
'''

相关问题