我需要在聊天中连续发送一系列数字,如下所示:
15
16
17
18
19
它需要点击输入每个数字
import pyautogui
from time import sleep
number = int(input("Counting from numbers? "))
timestoloop = int(input("How many numbers would you like to count up? "))
sleep(1) #put how many seconds you would like the delay to be there, in this case it is 1 second.
for x in range(timestoloop): # this will loop it the amount of times you entered into the input
print(number)
print(number)
pyautogui.write(f" {number},") #this is what types it
number += 1 # this will add 1 to it each time it loops.
需要点击输入每个数字
根据pyautogui
文档
换行符为Enter
因此,在数字后面添加n
就足够了,最小示例
import pyautogui
for i in [15,16,17,18,19]:
pyautogui.write(f"{i}n")
我喜欢这个,也一直使用这个,这里使用这个。
import pyautogui
import time
start, steps, end = 0, 1, 20
current = start
while current < end:
pyautogui.write(str(current), interval=0.25)
pyautogui.press('enter')
current += steps
只需在两者之间放入一个输入即可。每当你按下回车键,忽略pyautogui,输入的东西就会执行(基本上只是填空(。
number = 10 #eg
iterations = 10 #eg
for i in range(iterations):
input()
print(number)
number += 1