SMF For Free Support Forum

General Stuff => Programming => Visual Basic => Topic started by: |-|Java()|-| on July 18, 2007, 10:28:06 pm

Title: Find colour.
Post by: |-|Java()|-| on July 18, 2007, 10:28:06 pm
Remember, this returns the coordinates of the color in a window, not the position on the screen, you'll have to use GetWindowRect to get the rect and add the needed numbers to the coordinates for the position on the screen.

Code: [Select]
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long

Private Type POINTAPI
    X As Long
    Y As Long
End Type

Function FindColor(Color As Long, X1 As Long, Y1 As Long, X2 As Long, Y2 As Long, _
                            Window As Long) As POINTAPI
Dim xx As Long, yy As Long, TestDC As Long, WndRECT As RECT, temp As POINTAPI
    TestDC = GetDC(Window)
    For yy = Y1 To Y2
        For xx = X1 To X2
            If GetPixel(TestDC, xx, yy) = Color Then
                temp.X = xx
                temp.Y = yy
                FindColor = temp
                Exit Function
            End If
            DoEvents
        Next xx
    Next yy
    FindColor.X = -1
    FindColor.Y = -1
End Function

Enjoy  :cool:
Title: Re: Find colour.
Post by: rileyks on July 19, 2007, 08:12:01 am
Sorry...I don't even understand what this is for.
Title: Re: Find colour.
Post by: Kimmie on July 19, 2007, 06:41:40 pm
Sorry...I don't even understand what this is for.

It has to do with the Visual Basic Programming Language and has nothing to do with your forum. Its for people who use VB.  ;). I dont even know anyone that still uses it...my vb discs are sitting in the back of my vb book collecting dust  ;D.
Title: Re: Find colour.
Post by: mr_css on October 20, 2007, 06:17:11 pm
Quote
Sorry...I don't even understand what this is for.

It has to do with the Visual Basic Programming Language and has nothing to do with your forum. Its for people who use VB.

It is very easy to learn VB (Visual Basics) Is a programming language like Kimmie said. not used for your forums but of course for website developing.It is not used much anymore of course. with all of the programming and new languages.But it is rarely used for things that can be done. VB is very easy like i've said before.I'm only in the 7th grade and i have some knowledge of PHP,Java,Javascript,VB, & HTML.
Title: Re: Find colour.
Post by: Global on December 07, 2007, 02:24:49 am
Quote
Sorry...I don't even understand what this is for.

It has to do with the Visual Basic Programming Language and has nothing to do with your forum. Its for people who use VB.

It is very easy to learn VB (Visual Basics) Is a programming language like Kimmie said. not used for your forums but of course for website developing.It is not used much anymore of course. with all of the programming and new languages.But it is rarely used for things that can be done. VB is very easy like i've said before.I'm only in the 7th grade and i have some knowledge of PHP,Java,Javascript,VB, & HTML.
Visual Basics have nothing to do with Web Development (PHP, CSS, HTML, ect.).

Where did you get that idea?
Title: Re: Find colour.
Post by: Supernovadelta on June 17, 2008, 07:25:19 am
I'l try to find some tutorials for my self,so i can get use to these things.