button spammer python code example

Example 1: how to make a button spammer in python

import time
import keyboard

# Start of script
start_timer = input("How long would you like the start timer to be? In seconds please ")
space_between_spam = input("How long would you like the space between each keystroke? In seconds please ")
pressed_key = input("What key do you want to spam? ")

# Crash Prevention
key_crash_stopper = pressed_key.split()
len_crash = len(key_crash_stopper)
substring = input("One more time, please ")
count = pressed_key.count(substring)
if pressed_key == substring:
    print("To stop, press 's'")
    print("starting in", start_timer, "Seconds")
    time.sleep(int(start_timer))
    while True:
        keyboard.press(pressed_key)
        time.sleep(float(space_between_spam))
else:
    print("Please type the same letters!")

if count != 1:
    print("Only one letter!")
    exit()

if len_crash > 1:
    print("Only one letter!")
    exit()

Example 2: how to make a button spammer in python

import time
import keyboard # pip install keyboard

# Start of script
start_timer = input("How long would you like the start timer to be? In seconds please ")
space_between_spam = input("How long would you like the space between each keystroke? In seconds please ")
pressed_key = input("What key do you want to spam? ")

# Crash Prevention
key_crash_stopper = pressed_key.split()
len_crash = len(key_crash_stopper)
substring = input("One more time, please ")
count = pressed_key.count(substring)
if pressed_key == substring:
    print("To stop, press 's'")
    print("starting in", start_timer, "Seconds")
    time.sleep(int(start_timer))
    while True:
        keyboard.press(pressed_key)
        time.sleep(float(space_between_spam))
else:
    print("Please type the same letters!")

if count != 1:
    print("Only one letter!")
    exit()

if len_crash > 1:
    print("Only one letter!")
    exit()