是的,这就是我需要实现的目标,不要问为什么:) 因此,由于这主要是依赖于操作系统的东西,我将使用Windows或Linux(无论更简单) 我的计划每一秒都会: 1.做截图,分析板子和其他东西(我可以做) 2.然后将鼠标移动到某个XY并左键单击 就这样 我主要担心的是:是否有任何用于捕获屏幕截图的库,然后在屏幕上单击somwhere?
答案 0 :(得分:3)
之前我做过这件事 - 使用PIL获取屏幕截图,并使用pywinauto生成鼠标点击。
答案 1 :(得分:2)
使用ctypes和user32调用。这是第二部分:
from ctypes import *
windll.user32.SetCursorPos(x, y)
SendInput是您正在寻找的模拟鼠标点击的内容,这正是您点击所需的内容:http://kvance.livejournal.com/985732.html
点击代码如下(尝试过,效果很好):
from ctypes import *
user32 = windll.user32
# START SENDINPUT TYPE DECLARATIONS
PUL = POINTER(c_ulong)
class KeyBdInput(Structure):
_fields_ = [("wVk", c_ushort),
("wScan", c_ushort),
("dwFlags", c_ulong),
("time", c_ulong),
("dwExtraInfo", PUL)]
class HardwareInput(Structure):
_fields_ = [("uMsg", c_ulong),
("wParamL", c_short),
("wParamH", c_ushort)]
class MouseInput(Structure):
_fields_ = [("dx", c_long),
("dy", c_long),
("mouseData", c_ulong),
("dwFlags", c_ulong),
("time",c_ulong),
("dwExtraInfo", PUL)]
class Input_I(Union):
_fields_ = [("ki", KeyBdInput),
("mi", MouseInput),
("hi", HardwareInput)]
class Input(Structure):
_fields_ = [("type", c_ulong),
("ii", Input_I)]
class POINT(Structure):
_fields_ = [("x", c_ulong),
("y", c_ulong)]
# END SENDINPUT TYPE DECLARATIONS
FInputs = Input * 2
extra = c_ulong(0)
click = Input_I()
click.mi = MouseInput(0, 0, 0, 2, 0, pointer(extra))
release = Input_I()
release.mi = MouseInput(0, 0, 0, 4, 0, pointer(extra))
x = FInputs( (0, click), (0, release) )
user32.SendInput(2, pointer(x), sizeof(x[0]))
答案 2 :(得分:1)
您可以尝试使用Selenium的Selenium RC + python驱动程序。有浏览器截图的方法,并且有ClickAt方法,它采用坐标。