May-06-2020, 09:44 PM
Hi guys!
I've been making a keyboard history program called ClipboardHero in python which stores your last clipboard entries in a file. I have encountered two problems while making this program:
I would grateful if anyone could help!
The code:
I've been making a keyboard history program called ClipboardHero in python which stores your last clipboard entries in a file. I have encountered two problems while making this program:
- I need the Ctrl-C keys to activate the program even when the window is not in focus
- I need it to activate not only with Ctrl-C but with right-click+Copy as well
I would grateful if anyone could help!

The code:
from tkinter import * from tkinter import messagebox import winsound subMenu = Tk() subMenu.title("ClipboardHero") subMenu.attributes("-topmost", True) subMenu.overrideredirect(True) subMenu.withdraw() menuShown = False clipboardSaves = open("clipboard.txt", "a") clipboardSaves.close() def copy(): global menuShown clipboard = str(subMenu.clipboard_get()) clipboardSaves = open("clipboard.txt", "a+") clipboardSaves.write("\n" + clipboard) clipboardSaves.close() messagebox.showinfo("ClipboardHero - Clipboard saved", "Your current clipboard has been saved!\n" + clipboard) menuShown = False subMenu.withdraw() def hideMenu(): subMenu.withdraw() menuSHown = False def showMenu(event): global menuShown if menuShown == False: winsound.Beep(400, 300) winsound.Beep(600, 300) subMenu.deiconify() Label(subMenu, text = "Do you want to copy this text to ClipboardHero?").grid(row = 0, column = 0) yes = Button(subMenu, text = "Yes", width = 50, bg = "green", command = copy) yes.grid(row = 1, column = 0) no = Button(subMenu, text = "No", width = 50, bg = "red", command = hideMenu) no.grid(row = 2, column = 0) menuShown = True subMenu.mainloop() subMenu.bind("<Control-c>", showMenu)