简体   繁体   English

如果 cursor 被隐藏,我如何在应用程序中移动鼠标?

[英]How can I move my mouse in an application if the cursor is hidden?

I want to move my mouse to a set position in an application/game which hides the cursor.我想将鼠标移动到隐藏 cursor 的应用程序/游戏中的一组 position。 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.该移动适用于所有其他应用程序,如浏览器等。但只要 cursor 不再可见,它就不会移动。

Right now I just use this:现在我只是用这个:

pyautogui.click(a.index(b), hexcolpix.index(a), duration=1)

EDIT: check out this here if you do not understand my problem, these people have the same problem... https://www.anycodings.com/1questions/1159979/how-to-move-in-game-camera-using-python How to move 3D video game camera using Python?编辑:如果您不理解我的问题,请在此处查看,这些人也有同样的问题... https://www.anycodings.com/1questions/1159979/how-to-move-in-game-camera-using -python 如何使用 Python 移动 3D 视频游戏摄像机?

Well, your cursor DOES move, but it is just hidden, you can use the moveTo() function to make the cursor move without clicking yet好吧,您的 cursor 确实移动了,但它只是被隐藏了,您可以使用moveTo() function 使 cursor 移动而无需单击

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那么你可以知道 cursor 的 position 如果你使用position() function 打印它

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

This proves that the cursor moves even if it is hidden.这证明了cursor即使被隐藏也会移动。

I recommend you to check the official documentation .我建议您查看官方文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM