AutoPy是一个简单跨平台的 Python GUI工具包,可以控制鼠标,键盘,匹配颜色和屏幕上的位图。使用纯ANSI C编写而成,可运行在Mac OS X, Windows和 X11上。
Hello World示例:
import autopy
def hello_there_world():
??? autopy.alert.alert(“Hello, world”)
hello_there_world()
?
?
鼠标:
import autopy autopy.mouse.smooth_move(1, 1)
?
?
?
import autopyimport mathimport timeimport randomTWO_PI = math.pi * 2.0def sine_mouse_wave(): """ Moves the mouse in a sine wave from the left edge of the screen to the right. """ width, height = autopy.screen.get_size() height /= 2 height -= 10 # Stay in the screen bounds. for x in xrange(width): y = int(height * math.sin((TWO_PI * x) / width) + height) autopy.mouse.move(x, y) time.sleep(random.uniform(0.001, 0.003))sine_mouse_wave()