Simulate mouse move in 3D games?

↘锁芯ラ 提交于 2019-12-05 06:15:53

问题


Hi I made a human computer interface to control mouse using fingers using C++ and OpenCV in CodeBlocks IDE http://www.youtube.com/watch?v=-q5aXTg0pVE I want to use this in a 3D game like medal of honor

First I used SetCursorPos(x,y) it did not work so I switched to SendInput and mouse_event. They did work with a bug the character began pointing in all random directions and changing directions on its own.

Should I use directinput as the game uses directx. If so how? I have tried many tutorials but all speak about how to get data from mouse but not how to insert into the mouse stream I used both absolute and relative positioning but both failed the character is behaving odd


回答1:


Without seeing your code, this answer is a bit of a long shot, but here goes.

SendInput should work, but I think the game is interfering by using SetCursorPos itself. Many games reset the cursor to the centre of the screen each frame, so it doesn't hit the edge by accident.

Try using SendInput with relative mouse motion, so without the MOUSEEVENTF_ABSOLUTE flag in the MOUSEINPUT struct.



来源:https://stackoverflow.com/questions/5302473/simulate-mouse-move-in-3d-games

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!