2

Using Windows 10 64bit

I'm trying to learn how to code in python and I decided to make my first program a simple bot for a game.

The game is a downloadable game.

The goal is for my mouse to click a button at coordinates (200, 200)

I have tried many different ways to get this to work.

I've tried...

PyAutoGui implementation

pyautogui.click(200, 200)

pywin32 implementation

import win32api, win32con
def click(x,y):
    win32api.SetCursorPos((x,y))
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
    win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
click(10,10)

Any ideas? From what I understand I need to use a low level driver?

I just don't understand how to emulate it as if a real mouse was clicking

Community
  • 1
  • 1
  • Possible duplicate of [python win32 simulate click](http://stackoverflow.com/questions/2964051/python-win32-simulate-click) – vriesdemichael Oct 21 '16 at 09:10
  • 1
    Possible duplicate of [Game isn't detecting mouse click](https://stackoverflow.com/questions/39990565/game-isnt-detecting-mouse-click) – okie Oct 25 '19 at 08:05

3 Answers3

0

try pyautogui.mouseDown() or pyautogui.mouseUp() instead... info: https://automatetheboringstuff.com/chapter18/

0

Make sure, that you set the raw input checkbox in game settings for the mouse. I had the same issue with CSGO

0

Not sure if this will work with your game but you can use PyUserInput.

applehero
  • 19
  • 3