Home > Net >  How do i use range method with pyautogui
How do i use range method with pyautogui

Time:08-13

I was trying to brute-force a 4 digit pin protected website (my website) and I tried using pyautogui and I entered the following:

import pyautogui as pg

for i in range(1000 ,10000):
  pg.write(i)

but when i run it it gives me

Traceback (most recent call last):
  File "c:\Users\zeida\OneDrive\Desktop\Python\Training.py", line 4, in <module>
    pg.write(i)
  File "C:\Users\zeida\OneDrive\Desktop\Python\venv\lib\site-packages\pyautogui\__init__.py", line 598, in wrapper
    returnVal = wrappedFunction(*args, **kwargs)
  File "C:\Users\zeida\OneDrive\Desktop\Python\venv\lib\site-packages\pyautogui\__init__.py", line 1677, in typewrite       
    for c in message:
TypeError: 'int' object is not iterable

I tried typewrite aswell

import pyautogui as pg

for i in range(1000 ,10000):
  pg.typewrite(i)

and it outputted the same thing

can you tell me why is that happening and how to fix it?

CodePudding user response:

So what's happening is that you are giving pyautogui a number to write but the thing is that it can only write characters. What I mean is that you are giving it an integer (int) but it actually wants a string (str) so that it can iterate over it and type the characters. In this case,

    pg.typewrite(str(i))

this should do the trick.

  • Related