I basically want to type a word over and over into a document. But how do I type words line by line without for word in f:. I want it to keep going and loop back around to the beginning of the file.
import pyautogui, time, keyboard
time.sleep(10)
f= open("bot",'r')
for word in f:
pyautogui.typewrite(word)
pyautogui.press("enter")
time.sleep(0.5)
if keyboard.is_pressed('x'):
break
If you are looking for the 'for' loop to continuously keep running and updating the file even after it has terminated you can contain it under a while loop like,
import pyautogui, time, keyboard
time.sleep(10)
while(1):
f= open("bot",'r')
if keyboard.is_pressed('x'):
break
for word in f:
pyautogui.typewrite(word)
pyautogui.press("enter")
time.sleep(0.5)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.