简体   繁体   English

鼠标在python视频游戏中移动

[英]mouse move in python video game

This code causes my screen to go black 此代码使我的屏幕变黑

I am using PIL imagegrab to process images 我正在使用PIL imagegrab处理图像

whenever i make a call to move the mouse using the following code the screen goes black: 每当我使用以下代码致电移动鼠标时,屏幕就会变黑:

def MoveMouse(x, y):
    extra = ctypes.c_ulong(0)
    ii_ = Input_I()
    x = int(x*(65536/ctypes.windll.user32.GetSystemMetrics(0))+1)
    y = int(y*(65536/ctypes.windll.user32.GetSystemMetrics(1))+1)
    ii_.mi = MouseInput(x, y, 0, 0x0001 | 0x8000, 1, ctypes.pointer(extra))
    x = Input(ctypes.c_ulong(0), ii_)
    ctypes.windll.user32.SendInput(1, ctypes.pointer(x), ctypes.sizeof(x))

I also had that problem and it took WAY to long to figure it out, anyway for me the fix was to change in the line: 我也遇到了这个问题,花了很长时间才弄清楚,对我而言,解决方法是更改​​生产线:

ii_.mi = MouseInput(x, y, 0, 0x0001 | 0x8000, 1, ctypes.pointer(extra)) 

the fifth parameter (ie "1") to 0: 第五个参数(即“ 1”)为0:

ii_.mi = MouseInput(x, y, 0, 0x0001 | 0x8000, 0, ctypes.pointer(extra)) 

hope this helps. 希望这可以帮助。

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

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