2

I'm trying to set up a bot that does things for me, at the moment I have to be in the same window so that it works. Is it possible to be able to change my window (e.g using google chrome) while the bot is running on that specific application?

Also if you're asking about what application its, its Runescape just an old game and I'm just using it to learn more about python.

I couldn't find any information online about any module that does this sadly.

from pynput.mouse import Button, Controller
from time import sleep
from random import randint, uniform

def move_mouse(next_pos):
    sleep(uniform(0.1,0.2))
    mouse.position = (randint(int(round(next_pos[0])), int(round(next_pos[2]))), randint(int(round(next_pos[1])), int(round(next_pos[3]))))
    sleep(uniform(1,1.2))
    mouse.click(Button.left, 1)

mouse = Controller()
print(mouse.position)

shaft = [ 1299.25, 590.48828125, 1315.6171875, 610.69921875]
box = [705.01171875, 600.671875, 957.640625, 616.37109375]

sleep(2)
while True:
    move_mouse(shaft)
    move_mouse(box)
    sleep(71)

So far everything works perfectly I get no errors what so ever. All I need is for it to click on a specific application.

Elpupper
  • 46
  • 1
  • 12

0 Answers0