0% found this document useful (0 votes)
18 views2 pages

Autotext Pyw Code

The document outlines a Python program using Tkinter for creating an Auto Text Inputter application. It allows users to input text, set typing speed, and includes options for infinite repetition and treating spaces as enter. The application also features predefined autotext shortcuts for quick insertion of common phrases.

Uploaded by

jhx88x
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views2 pages

Autotext Pyw Code

The document outlines a Python program using Tkinter for creating an Auto Text Inputter application. It allows users to input text, set typing speed, and includes options for infinite repetition and treating spaces as enter. The application also features predefined autotext shortcuts for quick insertion of common phrases.

Uploaded by

jhx88x
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

import tkinter as tk

import time
import threading
import pyautogui

class AutoTextInputter:
DEFAULT_SPEED = 0.1 # Default typing speed

def __init__(self, master):


self.master = master
self.master.title("Auto Text Inputter")

# Text Entry for user input


self.text_entry = tk.Entry(master, width=50)
self.text_entry.pack(pady=10)

# Typing speed label and entry


tk.Label(master, text="Typing Speed (seconds):").pack()
self.speed_entry = tk.Entry(master, width=10)
self.speed_entry.pack(pady=5)
self.speed_entry.insert(0, str(self.DEFAULT_SPEED)) # Default speed

# Checkboxes for options


self.repeat_var = tk.BooleanVar()
tk.Checkbutton(master, text="Repeat Infinitely",
variable=self.repeat_var).pack()

self.space_as_enter_var = tk.BooleanVar()
tk.Checkbutton(master, text="Treat Space as Enter",
variable=self.space_as_enter_var).pack()

# Start and Stop buttons


tk.Button(master, text="Start Typing",
command=self.start_typing).pack(pady=10)
tk.Button(master, text="Stop Typing",
command=self.stop_typing).pack(pady=10)

# Dictionary for autotext


self.auto_texts = {
"hi": "Hello, how can I help you?",
"addr": "123 Main St, Springfield, IL 62701",
"email": "[email protected]",
"ph": "(555) 123-4567",
}

self.is_typing = False # Flag to control typing

def start_typing(self):
input_text = self.text_entry.get()
typing_speed = float(self.speed_entry.get())
self.is_typing = True # Set typing flag

threading.Thread(target=self.delayed_start, args=(input_text,
typing_speed)).start()

def delayed_start(self, input_text, typing_speed):


time.sleep(3) # 3-second delay before starting
self.type_text(input_text, typing_speed)
def stop_typing(self):
self.is_typing = False # Clear typing flag

def type_text(self, input_text, typing_speed):


# Replace shortcuts with corresponding autotext
for shortcut, text in self.auto_texts.items():
input_text = input_text.replace(shortcut, text)

while self.is_typing:
for char in input_text:
if char == ' ' and self.space_as_enter_var.get():
pyautogui.press('enter')
else:
pyautogui.typewrite(char)
time.sleep(typing_speed)

if not self.repeat_var.get():
break

if __name__ == "__main__":
root = tk.Tk()
app = AutoTextInputter(root)
root.mainloop()

You might also like