Click to See Complete Forum and Search --> : Question reguarding 'Point' command...


Cluel3ss
June 21st, 2001, 06:53 PM
Hi, I'm quite new to VB. I want to be able to get the colour (RGB values) of a pixel at a particular point on the screen for a certain window. I am able to use the Point command to do this for the VB form window, but I need to get the colour of a pixel which is in another window (i.e. another program, NOT my VB project window). Can anyone please help me out, give an example, etc? If so I would much appreciate it.

shree
June 21st, 2001, 07:06 PM
You cannot do this using Point. But there is an equivalent API function called GetPixel. The steps in solving your problem are

Get the handle to the application window using FindWindow().
Get the device context from this window using GetDC().
Then use GetPixel() to obtain the pixel color at that point.

If that does not daunt you ...

Cluel3ss
June 22nd, 2001, 04:55 AM
OK thanks a lot for that, I think I can handle using those API functions.
I just have 1 more question though. The title of the window I want to find is not always the same. The first few words are always the same, but then there is a '-' and some text after it which changes each time (much like the title of an Internet Explorer window, but the other way around). I notice that the FindWindow API does not support partial matches and that it has to find an exact match for the word(s), else it returns a 0 value. Any suggestions about getting around this?

shree
June 22nd, 2001, 08:23 AM
See this post, this might help you.

http://codeguru.com/cgi-bin/bbs/wt/showpost.pl?Board=vb&Number=40992