473,883 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Searching for pixel color

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=h...adburys&_m=EXT

Aug 19 '07 #1
1 1846
michael maver wrote:
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(d esired_color):
root = my_gui.root_win dow()
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.
Aug 19 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
8243
by: grogerteal | last post by:
Hello, I am pretty new to programming and would like someone to help me get started on the program that I need to make. I hope it is not hard to do, but what I would like is a simple app that has a label which returns the color of a pixel that is in position x,y on the screen (i.e. the desktop @ 1024 x 768 pixels), where x and y are of course variable.
1
1789
by: morangi | last post by:
<?php session_start(); error_reporting(E_ERROR && ~E_NOTICE && ~E_WARNING); ob_start(); $link = mysql_connect('localhost', 'root', 'test'); if (!$link) { die('Could not connect: ' . mysql_error()); } if (isset($_POST))
8
3553
by: ofiras | last post by:
Hi, I made a "Paint" program, but I couldn't find a method to paint 1 pixel using graphic state ("Graphics g = Graphics.FromHwnd(this.Handle);") How can I paint 1 pixel? I guess I can make a Bitmap, change one pixel color and show it, but I'm sure there is another way of doing it. Please help, Ofir.
1
3247
by: ofiras | last post by:
In bitmap, how can I find the nearest pixel (pixel 1) to a specific pixel (pixel 2) that has different color from pixel 2? Or how can I find a pixel in a specific distance from pixel 2 (like a circle that pixel 2 is his center, and I'm looking for a pixel that has different color that pixel 2)? (I'm trying to do a voronoi diagram maker, so I need to search for the nearest colored pixel in my bitmap for every pixel that is not colored...
9
4521
by: raylopez99 | last post by:
After refering to the below thread, I take it for C# Forms 2.0, there a way to draw a 1 pixel by 1 pixel rectangle, which I was able to do just now successfully. http://groups.google.com/group/microsoft.public.dotnet.languages.csharp/browse_thread/thread/59ed00adf5eef2d0/444f363036fc64f2?hl=en&lnk=gst&q=paint+a+pixel#444f363036fc64f2 But now the question is: has anybody ever done a 'scaling problem' for a grid where you are 'zooming...
0
9933
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11126
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10734
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9568
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7115
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5794
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5983
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4607
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4211
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.