Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

directx - Game is blocking Python mouse movements

I trained a cascade classifier for Audiosurf 2 to detect the blocks. Then I calculated the center coordinates of the block so I can move the mouse to that position while I'm playing.

Detected block with coordinates

But the cursor disappears when the game starts and I play as the ship moving left and right. My script does not move the mouse in the game. The game only registers the movements from my physical mouse. But when I pause the game, the mouse reappears and it centers on the block like it should. Click function on the block also does not work.

I tried several libraries: mouse, pyautogui, pydirectinput, and pynput. It's possible for me to get the current position of the mouse but cannot move it. None of them worked without having a cursor on screen. The keyboard presses from these libraries work fine however.

Several posts mentioned that games use directinput so I tried both win32api from this answer and ctypes from another answer. They also didn't work in game.

I feel like I exhausted all my options at this point. Any help would be appreciated.

question from:https://stackoverflow.com/questions/65836072/game-is-blocking-python-mouse-movements

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...