I am trying to make a program that will click a button really quickly for personal needs, but right now I’ve only come so far as to click the left button. I am trying to make a hotkey to turn it off, but it doesn’t work. I CANT USE THREADING, that’s why its all in the same loop.
from tkinter import *
from tkinter import messagebox
import pyautogui
import time
import keyboard
#3 We define the spam command
spamming=False
def off():
global spamming
spamming=False
def spam():
global clickidy
clickidy=tipidytype.get()
global spamming
spamming= True
while spamming==True:
pyautogui.click(clicks=1)
root.update()
try:
if keyboard.is_pressed("q"):
off()
except:
nothing=0
#1 Lets set up our window
root=Tk()
root["bg"]="#fafafa"
root.title("Sigma clicker")
root.geometry("400x110")
root.resizable(width=False, height=False)
frame=Frame()
frame.place(relx=0,rely=0,relheight=1,relwidth=1)
#2 Now we can add interface
title = Label(frame, text="Enter the button for spamming here")
title.place(x=15, y=15)
tipidytype=Entry(frame,bg="white")
tipidytype.place(x=15, y=45)
tester = Entry(frame, bg="white")
tester.place(x=250,y=45)
testtext=Label(frame, text="Focus here before starting")
testtext.place(x=250,y=15)
button = Button(frame,text=" On ", bg="gray", command=spam)
button.place(x=15,y=75)
off=Button(frame,text="Off", bg="gray", command=off)
off.place(x=250,y=75)
def window_exit():
global spamming
spamming=False
root.destroy()
root.protocol("WM_DELETE_WINDOW", window_exit)
root.mainloop()
I’ve tried making delays and two (2) different kinds of keyboard input(the listener didn’t work’ because it requires a loop).
New contributor
Carny pex is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.