Ad

Problem When Creating An Auto Typer Bot In Python

- 1 answer

I would like to create a bot that automatically copy and pastes whatever I have on my clipboard once every 1 min and something seconds. I want to use it on Discord. When I run the program, it copy and pastes fine, but then does not execute the enter command and does not send the message in discord. Here is my code, I used Pynput to simulate keystrokes. I'm new to python, this is my first program.

If anyone could help me in making a realistic bot that types a query character by character please Let me know. If anyone has Discord, my Discord is: Bitmap#7807

I use Python 3.5

import time

keyboard = Controller()

timeout = time.time() + 60*60*8 
time.sleep(4)
while True:
    test=0
    keyboard.press(Key.ctrl)
    time.sleep(0.5)
    keyboard.press('v')
    time.sleep(0.5)
    keyboard.release('v')
    time.sleep(0.5)
    keyboard.press(Key.shift)
    time.sleep(0.12)
    keyboard.press(Key.enter)
    time.sleep(0.12)
    keyboard.release(Key.enter)
    time.sleep(0.12)
    keyboard.release(Key.shift)
    time.sleep(0.12)
    keyboard.release(Key.ctrl)
    time.sleep(5)
    test = test+1

    if test == 261 or time.time() > timeout:
        break```
Ad

Answer

Don't you mean to release 'Ctrl' after releasing 'V'?
Also, I don't understand the 'Shift', are you trying to create a blank line afterwards?

Try this:

[...]
keyboard.press(Key.ctrl)
time.sleep(0.5)
keyboard.press('v')
time.sleep(0.5)
keyboard.release('v')
time.sleep(0.5)
keyboard.release(Key.ctrl)
time.sleep(0.5)
keyboard.press(Key.shift)
time.sleep(0.12)
keyboard.press(Key.enter)
time.sleep(0.12)
keyboard.release(Key.enter)
time.sleep(0.12)
keyboard.release(Key.shift)
time.sleep(0.12)
keyboard.press(Key.enter)
time.sleep(0.12)
keyboard.release(Key.enter)
time.sleep(5)
[...]
Ad
source: stackoverflow.com
Ad