Files
autoTyper/main.py
2025-04-08 18:45:35 +03:00

35 lines
952 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import time
from pynput.keyboard import Controller
import random
from tqdm import tqdm
delayRange = [0.15, 0.4] # default is 0.15, 0.4
def type_text(file_path):
keyboard = Controller()
try:
with open(file_path, 'r', encoding='utf-8') as file:
text = file.read()
print("Начинаю печатать, у вас есть 5 секунд на переключение в нужное окно")
for i in range(5, 0, -1):
print(i)
time.sleep(1)
for char in tqdm(text):
keyboard.type(char)
time.sleep(random.uniform(delayRange[0], delayRange[1]))
print("Печать завершена!")
except FileNotFoundError:
print(f"Файл {file_path} не найден")
except Exception as e:
print(f"Произошла ошибка: {e}")
file_path = "input.txt"
type_text(file_path)