Skip to content

Instantly share code, notes, and snippets.

@falsetru
Created September 5, 2011 08:20
Show Gist options
  • Save falsetru/1194405 to your computer and use it in GitHub Desktop.
Save falsetru/1194405 to your computer and use it in GitHub Desktop.
click
import win32api
import win32con
from time import sleep
import Image
import pywinauto
app = pywinauto.Application.start('mspaint')
win = app.top_window_()
win.MoveWindow(0,0)
def click(x,y):
win32api.SetCursorPos((x,y))
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN,x,y,0,0)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,x,y,0,0)
im = Image.open(r'c:\a.png')
for i in range(im.size[0]):
for j in range(im.size[1]):
if im.getpixel((i, j)) < 200:
click(50+i, 200+j)
sleep(0.01)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment