Home > Mobile >  Type a sequence of numbers using Python PyAutoGui
Type a sequence of numbers using Python PyAutoGui

Time:10-05

I need to send a sequence of numbers in row in a chat, like this:

15

16

17

18

19

It need to hit enter each number

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.

CodePudding user response:

need to hit enter each number

According to pyautogui docs

newline is Enter

So it should suffice to add \n after number, minimal example

import pyautogui
for i in [15,16,17,18,19]:
    pyautogui.write(f"{i}\n")

CodePudding user response:

I love this and also use this all the time, here use this.

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

CodePudding user response:

Just put an input in between. Whenever you press enter, ignoring the pyautogui, the input thing executes (just a fill in the blank, basically).

number = 10 #eg
iterations = 10 #eg
for i in range(iterations):
    input()
    print(number)
    number  = 1 
  • Related