Skip to content

Instantly share code, notes, and snippets.

@MatteoGauthier
Last active August 22, 2023 12:13
Show Gist options
  • Save MatteoGauthier/717282c1dcb46352ac10bff3b7ca6690 to your computer and use it in GitHub Desktop.
Save MatteoGauthier/717282c1dcb46352ac10bff3b7ca6690 to your computer and use it in GitHub Desktop.
import time
import random
from pynput.keyboard import Controller
keyboard = Controller() # Create the controller
def type_string_with_delay(string):
for character in string: # Loop over each character in the string
keyboard.type(character) # Type the character
delay = random.uniform(0, 2) # Generate a random number between 0 and 10
time.sleep(delay) # Sleep for the amount of seconds generated
type_string_with_delay("This is my string typed with a delay")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment