1

I was trying to make a spam bot using python but it doesn't work when I try to make it arabic but it works perfectly when I make it english I really need help quickly

This is the code

time.sleep(5)

f = open('spam.txt','r')
fa = f.encode("utf-8")
for word in fa:
    pyautogui.typewrite(word)
    pyautogui.press("enter")

spam.txt مرحبا

Thanks in advance

4 Answers4

2

Pyautogui, I'm think, works of your keyboard and there for can't recognise some characters perhaps, I'm not sure but you can send it through a copy paste command like so.

import pyautogui
import pyperclip
import time

time.sleep(5)

# Store our string to the clipboard
pyperclip.copy("مرحبا")
# Hotkey the paste command
pyautogui.hotkey("ctrl", "v")

Tested with into a text document and it is sending the characters just fine although it may depend on the app as to weather it will display left to right or right to left. From what I understand there are characters in Unicode that tell it what side to display if you need to.

For a spam bot put it into a text document read it then put each line in your clipboard.

Rabbitminers
  • 315
  • 3
  • 11
0

unfortunately, the Pyautogui doesn't support Arabic or Persian languages, for solve this problem you can type a word in TextPad then copy this manually and use hotkey to do this

from pyautogui import click, press, hotkey
# text 
def type():
            click(1000,701)
            hotkey("ctrl","v")
            press("enter")
            sleep(1)

   
0

you can use pywinauto library instead. It works perfectly. Try this:

from pywinauto.keyboard import send_keys

time.sleep(1)
send_keys(' سلام {ENTER 2}some more textt{BACKSPACE}', with_spaces=True)

remeber to add this library with

pip install pywinauto

Hamid Reza
  • 492
  • 1
  • 4
  • 14
0

you can also use this

msg=pyperclip.copy("اسپم")
for n in range(10):
    pyautogui.hotkey("ctrl","v")
    pyautogui.press("Enter") 
    time.sleep(0.5)