0

I have successfully found out how to move, drag, and click in Minecraft with python code. The only thing is that I have gotten the cursor to work in the inventory/crafting menu. One line I used to go up was

pyautogui.moveRel(0, -33, duration=0.1)

For some reason, this does not work outside the crafting menu. I am not able to move the camera in the open-world part of Minecraft. I had a problem with the keyboard as well, it would type the keys I would want it to in a text box but not in the real game. I fixed this by using keyboard.press() and keyboard.release() instead of using pyautogui. Pyautogui works for clicking and moving in the crafting menu but not in the real game.

Any thoughts on how to move the camera in-game?

Garousome
  • 21
  • 8

3 Answers3

1

Pyautogui does not work on video games on Windows or any other common OS. I suggest trying https://pypi.org/project/mouse/, as the keyboard function worked for other people.

CheetSheatOverlode
  • 121
  • 1
  • 1
  • 11
  • Can you provide a source for the statement "Pyautogui does not world [_sic_] on video games on Windows or any other common OS"? – Brian61354270 Mar 03 '20 at 01:15
  • I learned how use pyautogui from this website: https://automatetheboringstuff.com/2e/chapter20/. In there, there's a box saying it doesn't work on Windows. I tried it on Mac, and it doesn't work either. I know those are not the only common OS, but they are the ones I see the most. I suggest using the website I listed. – CheetSheatOverlode Mar 03 '20 at 01:18
  • pyautogui didn't work for me either on windows when making a bot for Guitar Hero 3. Ctypes + some low level windows APIs ended up working instead. – Robert Bain Jun 29 '21 at 04:04
0

Pyhon DirectInput Mouse Relative Moving act not as expected

Looking at this, I found the answer. I was trying to move the mouse where the game has a specific directinput I needed to use. I just called MouseMoveTo() with the desired numbers.

For some reason it only works like this MouseMoveTo(0,100,) with the added comma at the end

Garousome
  • 21
  • 8
  • Still doesnt work for me. Printing out the mouse position before and after running that function results in the same value. And no camera rotation applied. – Gunner Stone Mar 29 '23 at 07:58
0

I got it to work by turning off Raw Input in the Mouse Settings. Which are in Options > Controls > Mouse Settings > Raw Input