V
V
VuztreeCalan2018-07-23 21:57:12
Python
VuztreeCalan, 2018-07-23 21:57:12

How to smooth simulated typing in Python3?

There is the following code:

heroStory = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore"
    for i in heroStory:
        print(i, sep="", end="")
        sleep(0.04)

I tried to imitate typing with them, but that's bad luck, instead of smooth typing, python spits out half a word or at least a few characters. Is there any way to fix this to make it look smoother?
UPD: And on the command line of Windows, it spits out all the text at once

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
planc, 2018-07-23
@VuztreeCalan

print(i, end="", flush=True)

A
Alex F, 2018-07-25
@delvin-fil

#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
import pyautogui #грузим pyautogui
scri = pyautogui.size() #определим размер экрана
mous_pos = pyautogui.position() # определим позицию курсора
#pyautogui.moveTo(mous_pos[0]+100, mous_pos[1]+100, duration=1) 
#Перемещение в вашем случае не обязательно - это пример
pyautogui.typewrite('\nСейчас я напечатаю десять символов в секунду!\n', interval=0.1)
print (scri, mous_pos[0], mous_pos[1]) # распечатаем позицию курсора мыши

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question