简体   繁体   中英

Setting the position of the mouse cursor programmatically in wxPython

Is there a way for me to programatically set the position of a mouse cursor in wxPython?

For example, I would like to implement a sticky behavior with the mouse pointer, where in when the mouse pointer get closer to a particular position (x0, y0), then it gets positioned at (x0, y0).

There is pymouse module .

import pymouse
m = pymouse.PyMouse()
m.move(1,1)

Try using the frame's WarpPointer method. See http://www.wxpython.org/docs/api/wx.Window-class.html , a class that wx.Frame inherits from. Note that wxPython can probably only manipulate the mouse when it is inside a wx program. If it is outside the program, then you will need something like pymouse or something OS specific, like PyWin32.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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