📅  最后修改于: 2023-12-03 15:35:41.580000             🧑  作者: Mango
In Python, we can use the Win32 API to set the position of the mouse cursor on the screen. This can be useful in applications where we need to programmatically move the mouse cursor.
To use the Win32 API, we need to install the pywin32
package. This can be installed using pip:
pip install pywin32
Here is an example code snippet that uses the Win32 API to move the mouse cursor to a specific position:
import win32api
# Set the position of the mouse cursor
win32api.SetCursorPos((x, y))
Where x
and y
are the coordinates of the position we want to set the mouse cursor.
(0, 0)
position for the mouse cursor is the top-left corner of the screen.Using the Win32 API, we can easily set the position of the mouse cursor in Python. This can be useful in a wide range of applications, from automation to gaming.