Skip to content

Commit 21cee51

Browse files
authored
Create autoclicker.py
1 parent 9489ce1 commit 21cee51

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

autoclicker.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
'''
2+
Automatic Mouse Click based on screen contents
3+
Waits until the pixel at coordinates (364, 278) have the RGB color (75, 219, 106), then clicks
4+
'''
5+
6+
import gtk.gdk
7+
import sys
8+
from pymouse import PyMouse
9+
from time import sleep
10+
11+
m = PyMouse()
12+
13+
def PixelAt(x, y):
14+
w = gtk.gdk.get_default_root_window()
15+
sz = w.get_size()
16+
pb = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB,False,8,sz[0],sz[1])
17+
pb = pb.get_from_drawable(w,w.get_colormap(),0,0,0,0,sz[0],sz[1])
18+
pixel_array = pb.get_pixels_array()
19+
return pixel_array[y][x]
20+
21+
def main():
22+
while True:
23+
x = m.position()[0]
24+
y = m.position()[1]
25+
r, g, b = PixelAt(x, y)
26+
print m.position(), " == ", r, g, b
27+
28+
r, g, b = PixelAt(364, 278)
29+
if (r, g, b) == (75, 219, 106):
30+
print "green = click!"
31+
m.click(400, 223)
32+
33+
main()

0 commit comments

Comments
 (0)