ReggX / pydirectinput_rgx

Python mouse and keyboard input automation for Windows using Direct Input.
Other
52 stars 6 forks source link

No mouse clicks in games using Unity #3

Closed MAC-GH closed 1 year ago

MAC-GH commented 1 year ago

Hello,

I would like to have some feedback on the following questions:

All these questions because I've tried some quick examples and never got the primary / left clicks working with Python 3.11.2 on Windows 10. Running the code with admin privileges did not help. The examples (mouse moves and clicks) worked fine for everything but games with either PyAutoGUI, PyDirectInput and PyDirectInput-RGX.

Thanks and regards, Mac

ReggX commented 1 year ago

From my quick testing, Mouse clicks work just fine in Unity games. (Just tested in an isometric puzzle game, Railbound, and a classic FPS, Ultrakill).

For future reference, if you have an application where pydirectinput-rgx is not working, provide the application name and the code used to test it.

As for your questions, I'm not interested in building a cheat program, so if games create anti-cheat measures to specifically prevent artifical input, then I won't be providing support for said games.

MAC-GH commented 1 year ago

Hello,

While I agree that cheating is bad I do not see what I'm trying to achieve as a cheat which is automating game playing in MTG Arena in order to complete daily quests (such as "Cast 20 red or green spells" => see the attached screenshot crop or if you are not familiar with the game there are plenty of videos are available on YouTube explaining the gameplay). Screenshot 2023-03-15 203138. Completing quests this way would give me game credits while saving me time and also offering my opponents easy wins which brings them additional benefits.

Briefly, I'm trying to do my own version of this: https://www.youtube.com/watch?v=8RIIMyDkq1o and the starting code is really simple:

import time import pyautogui time.sleep(3) pyautogui.moveTo(211, 72) pyautogui.click()

or

import time import pydirectinput time.sleep(3) pydirectinput.moveTo(211, 72) pydirectinput.click() time.sleep(1) pydirectinput.moveTo(555, 555, duration=2) pydirectinput.click() time.sleep(1) pydirectinput.leftClick(211, 72, duration=2)

While trying this code also I found that the pyautogui's and pydirectinput's coordinates do not coincide (at least for the 211, 72 point).

Thanks and regards, Mac

ReggX commented 1 year ago

Just tried the game, your code is fine, but it looks like it doesn't support DirectInput, so you are out of luck with using this library.

There may be other ways to achieve your goals, but unfortunately this project won't be able to help you.

Hope you find a successful method elsewhere.

Regards.

ReggX commented 1 year ago

Let me take that back. I forgot that game installer started the game running with higher privileges (Run as Admin). It works just fine when the game is launched from the same unpriviledged user account as the python program.

Your code does work and does exactly what it's programmed to do. Keep in mind that pydirectinput-rgx has fixes in place for inaccurate Windows coordinate transformation, so your given coordinates should match up to the pixel coordinates of the screen.

In cases where the fix is not enough and you need pixel perfect accuracy, you can try adding attempt_pixel_perfect=True to your mouse move functions to make slight corrections and hit the exact pixel.