Brand new to programming....
I am trying to set up a program that can be controlled using keyboard shortcuts. I want the keyboard shortcuts to be linked to specific excel files. I have figured out how to open the excel files by themselves but now I want to attach the shortcuts to them. This is all I have:
import os
os.system('start C:\mold\MoldFlowMaster_exce.xlsx')
答案 0 :(得分:1)
This makes a Tkinter window which you can type in to. If the 'shortcut' (in this code, 'a') is pressed, you can cause something to happen such as opening your Excel file.
import tkinter as tk
import os
def onKeyPress(event):
if event.char == 'a':
os.system('start C:\mold\MoldFlowMaster_exce.xlsx')
root = tk.Tk()
root.geometry('300x200')
text = tk.Text(root, background='black', foreground='white', font=('Comic Sans MS', 12))
text.pack()
root.bind('<KeyPress>', onKeyPress)
root.mainloop()