0

I want to move my mouse to a set position in an application/game which hides the cursor. The movement works on all other applications like in a browser etc. But as soon as the cursor is not visible anymore, it won't move.

Right now I just use this:

pyautogui.click(a.index(b), hexcolpix.index(a), duration=1)
General Grievance
  • 4,555
  • 31
  • 31
  • 45
  • If the cursor is not visible, how do you know that it doesn't move? – mkrieger1 Sep 27 '22 at 14:47
  • What's the problem with this line of code? – mkrieger1 Sep 27 '22 at 14:48
  • I found the Problem here aswell btw. https://www.anycodings.com/1questions/1159979/how-to-move-in-game-camera-using-python – Malik Kocan Sep 27 '22 at 15:03
  • And to answer your Questions @mkrieger1: I know it doesn't move, because it does not control/change something in the application what a "normal" movement of my mouse would do. And there is no Problem with this line of code, it works perfectly Well, it just does not work in this specific case of an application which hides the cursor... – Malik Kocan Sep 27 '22 at 15:07

2 Answers2

1

Well, your cursor DOES move, but it is just hidden, you can use the moveTo() function to make the cursor move without clicking yet

pyautogui.moveTo(100, 200)   # moves mouse to X of 100, Y of 200.

then you can know the position of the cursor if you print it using the position() function

pyautogui.position()   # (160, 500) for example

This proves that the cursor moves even if it is hidden.

I recommend you to check the official documentation.

Abdel
  • 404
  • 2
  • 8
  • Yes, I know that is moves, but I need it to control things in the Application... (Sry if I created a misunderstanding) – Malik Kocan Sep 27 '22 at 14:59
  • That part wasn't mentionned in your question, for this, there are multiple ways to do it, the easiest one, is to get the position of each thing you want to click on the application the work with the coordinates you've got, or, if you want more thant that, I don't think pyautogui is what you are looking for, this library is just for simple automation, you can use [Tensorflow](https://stackoverflow.com/questions/44622871/shape-detection-tensorflow) or [OpenCV](https://www.geeksforgeeks.org/detect-an-object-with-opencv-python/) for image recognition. – Abdel Sep 27 '22 at 15:06
  • I already did the Image recognition part... (The code is supposed to find a certain color on the screen and click it. Everything works just fine exept for the Problem posted above) I just need my mouse to be able to move in applications that hide the cursor and control what is happening... What I did, was find out, that Tesorflow works wit hpynput, so I tried out that, but that did not work either... – Malik Kocan Sep 27 '22 at 15:37
0

some games had this problem for me first u need to make sure that u running the code as administrator if the game was first opened as administrator or it's launcher was.

if the game is a full screen mode(which i probably guess it is) for some reason idk why some full-screen games dont work with moveto commands or other ,etc. so i had to make sure it is in a windowed mode example:

in amongus game i dont need to make it windowed but in a game named asda global i had to make sure it is windows for my script to work

problem is if this was really the case ... what u do if the game dont allow u to change to window mode ?

Basem Ayad
  • 19
  • 5