Searching for pixel color

M

michael maver

Hello, I was just wondering if anyone knew of a way to search the screen for
a certain color in Python.

I know it is possible to do this in other languages, but I'm not sure how
I'd go about doing this in Python. Just to let you know, I'm running windows
XP and I don't really need it to be a cross platform solution, but if it was
that'd be an extra bonus.

Thanks very much for taking the time to read this and, hopefully, respond!

_________________________________________________________________
Advertisement: Win Dad the Footy Final with Cadbury Favourites!
http://a.ninemsn.com.au/b.aspx?URL=...r=hotmail_email_tagline_Aug07_Cadburys&_m=EXT
 
S

samwyse

michael said:
Hello, I was just wondering if anyone knew of a way to search the screen
for a certain color in Python.

I know of lots of ways to do this...
I know it is possible to do this in other languages, but I'm not sure
how I'd go about doing this in Python. Just to let you know, I'm running
windows XP and I don't really need it to be a cross platform solution,
but if it was that'd be an extra bonus.

.... but they are all platform dependent; not just Windows vs Unix, but
PIL vs wxWin vs whatever.

def search_screen(desired_color):
root = my_gui.root_window()
width, height = root.get_size()
for x in xrange(0, width):
for y in xrange(0, height):
if root.get_pixel(x,y) == desired_color:
return x,y
return -1, -1

Modify the above using the appropriate values for 'my_gui' and its
methods, 'root_window', 'get_size' and 'get_pixel'.
> Thanks very much for taking the time to read this and, hopefully,
respond!

You're welcome.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Notepad Font Defaults 1
Ruby .exe Maker 2
Maths in Ruby 12
File Question 7

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top