开发者

Python xlib warp_pointer not working properly inside games

I am trying to change the mouse pointer using py开发者_开发百科thon xlib. I successfully did it using warp_pointer. But when i try to play any games like Secret Maryo Chronicles, the mouse pointer moves to the rightmost corner of the screen and not the specified location. Why is it so? Can anyone help me with this?


It looks like contrary to what the documentation says, it is an absolute coordinate, not an offset.

I tried this and it worked as expected if you think of coordinates as absolute coordinate with 1,1 (or 0,0 ) starting at the top left corner of the window.

from Xlib import X, display
import time

d = display.Display()
s = d.screen()
root = s.root
root.warp_pointer(500,500)
d.sync()

time.sleep( 5 )
root.warp_pointer(250,250)
d.sync()

time.sleep( 5 )
root.warp_pointer(100,100)
d.sync()

time.sleep( 5 )
root.warp_pointer(250,250)
d.sync()


I'm not familiar with SMC. It may be that it uses warp_pointer itself. I know a lot of games do to simulate the relative motion support only recently introduced to XInput and I think some of them use it to stash the mouse "out of the way". Have you tried it with games that do different things with the mouse?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜