鼠标在python视频游戏中移动 [英] mouse move in python video game

查看:102
本文介绍了鼠标在python视频游戏中移动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码使我的屏幕变黑

我正在使用PIL imagegrab处理图像

I am using PIL imagegrab to process images

每当我使用以下代码致电移动鼠标时,屏幕就会变黑:

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)) 

第五个参数(即"1")为0:

the fifth parameter (i.e. "1") to 0:

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

希望这会有所帮助.

这篇关于鼠标在python视频游戏中移动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆