Ad
Problem When Creating An Auto Typer Bot In Python
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
Related Questions
- → What are the pluses/minuses of different ways to configure GPIOs on the Beaglebone Black?
- → Django, code inside <script> tag doesn't work in a template
- → React - Django webpack config with dynamic 'output'
- → GAE Python app - Does URL matter for SEO?
- → Put a Rendered Django Template in Json along with some other items
- → session disappears when request is sent from fetch
- → Python Shopify API output formatted datetime string in django template
- → Can't turn off Javascript using Selenium
- → WebDriver click() vs JavaScript click()
- → Shopify app: adding a new shipping address via webhook
- → Shopify + Python library: how to create new shipping address
- → shopify python api: how do add new assets to published theme?
- → Access 'HTTP_X_SHOPIFY_SHOP_API_CALL_LIMIT' with Python Shopify Module
Ad