#!/usr/bin/python import Image import sys im = Image.open("test.bmp") ix, iy = im.size if ix > 256 or iy > 180: print "too big!" sys.exit(0) BASE_X = 50 BASE_Y = 220 pix = im.load() down = False for y in range(iy): for x in range(ix): new_down = (pix[x, y] == 0) if new_down and not down: print "mousemove %d %d" % (BASE_X + x*3, BASE_Y + y*3) print "mousedown 1" elif not new_down and down: print "mousemove %d %d" % (last_draw_x, last_draw_y) print "mouseup 1" last_draw_x, last_draw_y = (BASE_X + x*3, BASE_Y + y*3) down = new_down down = False print "mousemove %d %d" % (last_draw_x, last_draw_y) print "mouseup 1"