我正在制作一个能够打开discord、google chrome、epic games launcher、steam等程序的程序。我将如何查找这些程序在设备(Windows 10)上的安装位置。我做了一些研究,有一个东西叫做Windows注册表,但我不知道如何制作它,这样你就可以得到.exe文件来启动程序
from tkinter import *
def WindowCentre():
positionRight = int(Main.winfo_screenwidth() / 2 - 960 / 2)
positionDown = int(Main.winfo_screenheight() / 2 - 540 / 2)
Main.geometry("+{}+{}".format(positionRight, positionDown))
def ButtonClick(Application):
# Whatever the code is for here
# pass is just for the error
pass
Main = Tk()
Main.title("Program Launcher")
# Main.iconbitmap("")
Main.configure(bg="#2c2f33")
Main.geometry("960x540")
WindowCentre()
DiscordImage = PhotoImage(file="Images/Discord Icon.png")
DiscordButton = Button(image=DiscordImage, activebackground="#2c2f33",
activeforeground="#2c2f33", bg="#2c2f33",
width=150, height=150, borderwidth=0,
command=lambda: ButtonClick("Discord"))
DiscordButton.grid(row=0, column=0, padx=10, pady=10)
EpicGamesImage = PhotoImage(file="Images/Epic Games Launcher Icon.png")
EpicGamesButton = Button(image=EpicGamesImage, activebackground="#2c2f33",
activeforeground="#2c2f33", bg="#2c2f33",
width=150, height=150, borderwidth=0,
command=lambda: ButtonClick("Epic Games Launcher"))
EpicGamesButton.grid(row=0, column=1, padx=10, pady=10)
Main.mainloop()
那么,我怎样才能让程序找到程序在任何windows设备上的安装位置,然后让gui上的按钮在单击时打开它呢?我可以只使用默认目录,但大多数程序都可以选择更改安装位置,因此我正在寻找一种查找程序安装位置的方法
谢谢任何人的帮助
编辑
我想知道这是否能与启动该计划一起工作?Windowsapps查找exe的AppID。我不知道如何用这个来启动这个项目,有人能帮我弄明白吗
import windowsapps
name, appid = windowsapps.find_app('Discord')
#searches for the APPLICATION NAME and returns:-
#name = Name of the application.
#appid = AppId of the application
print(name)
print(appid)
您将能够通过
os.walk
函数找到这些文件使用此方法,您将能够找到所需的exe 您可以通过
os.path.join
进入安装位置这里有很好的记录http://docs.python.org/3/library/os.html#os.walk
相关问题 更多 >
编程相关推荐