'Pyautogui typewrite() really slow
I'm making a bot to play Nitro Type for me. I'm using Pyautogui typewrite() to type out the text but it is way slower than it should be. Without a time.sleep() added to it, it is only typing at 111 WPM when. Then when I add the delay which is set to 0.019546153826607692 it gets 70 I'm pretty sure it is my fault but I don't know what I did wrong any help would be appreciated. Oh and here is the code for that part of it.
for i in range(1):
driver.get('https://www.nitrotype.com/race')
time.sleep(5)
html = driver.page_source.replace(' ', ' ')
f = open("word.html", "w")
f.write(html)
f.close()
with open("word.html", "r") as html_file:
content = html_file.read()
soup = BeautifulSoup(content, 'lxml')
words = soup.find_all('span', class_='dash-letter')
stuff = ""
for span in words:
if span.text.isascii():
stuff += span.text
with open("Sentence.txt", "w") as wf:
wf.write(stuff)
wf.close()
e = open('Sentence.txt', 'r')
s = e.read()
Words = len(s.split())
Characters = len(s)
delay1 = (WPM * Characters) / Words
delay2 = delay1 / 60
delay3 = Characters / delay2
Delay = (delay3 / Characters)
print(Delay)
for word in s:
pyautogui.typewrite(word)
time.sleep(Delay)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|