• Log in or sign up for an account here: https://www.sythe.org/login

[REQUEST] Bare-bone colour picking

Blupig

BEEF TOILET

$5 USD Donor
Joined
Nov 23, 2006
Sythe Gold
1,609
Messages
7,145
Age
33
Location
Canada
Valentine's Singing Competition Winner
Sythe Awards 2015 Winner
Sythe Awards 2016 Winner
Sythe Awards 2020 Winner
Member of the Month Winner
MushyMuncher
Gohan has AIDS
Extreme Homosex
World War 3
I'm LAAAAAAAME
Discord Verified
Off Topic Participant
I've tried to assemble a colour-click program on my own using a mix-up of sources, but can never do it...It would be nice for someone more experienced than me to post a source to help me with the usage of colour clicking. I've already looked at the Jaghax autofighter source by TK, but I was blinded by too many features and complicated aspects of the program. Help please?
 
Declarations:
Code:
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, _
    ByVal x As Long, ByVal y As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) _
        As Long
Private Declare Function ReleaseDC Lib "user32" ( _
ByVal hwnd As Long, _
ByVal hdc As Long _
) As Long

Private Type COORDS
x As Integer
y As Integer
End Type

FindColor Function:
Code:
Private Function FindColor(StartX As Long, StartY As Long, EndX As Long, EndY As Long, Color As Long, Color2 As Long) As COORDS

Dim i As Long, j As Long, n As Long, lDC As Long, CurrentPixel As Long
lDC = GetWindowDC(0)
    
For j = StartY To EndY Step 1
    For i = StartX To EndX Step 1
    
        CurrentPixel = GetPixel(lDC, i, j)
        If CurrentPixel = Color1 Then
            FindColor.x = i
            FindColor.y = j
            ReleaseDC 0, lDC
            Exit Function
        ElseIf CurrentPixel = Color2 Then
            FindColor.x = i
            FindColor.y = j
            ReleaseDC 0, lDC
            Exit Function
        End If
    Next i
Next j

ReleaseDC 0, lDC
End Function

Not a sexy spiral like Cruel's but it gets the job done by finding colors in a square/rectange you specify by telling it the coordinates of the top left corner and the bottom right corner of the area. Also, it can be easily converted to become FindColorTolerance. Don't be too negative, I did make this from scratch. :)

If you decide to use it and have any questions or want to go about adding tolerance just add me on MSN as it's probably easier.
 
He means to say that it is a nice piece of code, and you are saying it is bad.
Thanks!:o

I made that on my own from nothing.:D
 
Runescape Gamblingrunescape gambling
Back
Top