im new to programing in general and im trying to make a simple program using pyautogui and tkinter to make some basic automation in this case holding a specified key down. However i dont understand what is the problem since the program compiles but nothing really happens heres the code (if u could guide me to some basic learning resources id also be gratefull)
import pyautogui
import time
import keyboard
import random
import win32api, win32con
from tkinter import *
def click(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,1,1)
time.sleep(0.1)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,1,1)
def retrieve():
hold(key_entry.get())
print('here')
def hold(key_entry):
pyautogui.press(key_entry)
#print(key_entry)
root = Tk()
root.geometry("600x450")
frame = Frame(root)
frame.pack()
key_input_explanation = StringVar()
key_input_explanation.set("input the key u want to be held down. only input a singe key otherwise it wont work")
delay_input_explanation = StringVar()
delay_input_explanation.set("input the delay u want. only input a singe digit otherwise it wont work")
#explains the user what to input
label = Label(frame, textvariable = key_input_explanation )
label.pack()
#the user inputs the key to be held down
key_entry = Entry(frame, width = 1)
key_entry.pack(padx = 5, pady = 5)
#explains the user what to input
label = Label(frame, textvariable = delay_input_explanation )
label.pack()
#the user inputs the time before the key is held down
delay_entry = Entry(frame, width = 2)
delay_entry.pack(padx = 5, pady = 5)
#the user must press this to send the info
button = Button(frame, text = "Submit", command = retrieve)
button.pack(padx = 5, pady = 5)
root.title("why wont this work ")
root.mainloop()