Free Games Forum
Free Games Games Forums Music Forums TV Forums

  Free Games Forum Home FORUM
HOME
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN
Rules & FAQ RULES / FAQ
REPORT SPAM

Free Games Forum: Game Technology: Visual Basic / VB:
I'm trying to figure out how to locate a color on the users screen, can anybody help?

 

 


brownhead
Member

Jan 1, 2006, 1:45 PM

Post #1 of 17 (501 views)
Shortcut
I'm trying to figure out how to locate a color on the users screen, can anybody help? Can't Post

I've been working on an advanced AutoClicker and it hasn't gotten much popularity in the game boards because it can't search for colors(The user defines a color then the program searches the screen and comes up with an X and Y coordinate). Anybody knowhow to do this. My attempt at checking every pixel on the screen didn't work out very well... at all. I'm hoping for just a simple function but any code would be great. Thankya all, and G'dayLaugh


-------------------------------------


[img]http://i25.photobucket.com/albums/c51/70k0/BHU.png[/img]

(This post was edited by brownhead on Jan 1, 2006, 1:52 PM)



terrankiller
Veteran


Jan 2, 2006, 4:41 AM

Post #2 of 17 (494 views)
Shortcut
Re: [brownhead] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post

You can use Cruel Machines findcolorspiral function:

http://www.cruels.net/viewtopic.php?t=176



You can use this function as well:

Private Function ColorSearch(color, x1, y1, x2, y2 As Long) As POINTAPI
Dim x As Long, y As Long, xy As String
Dim StrTemp As String, XYarr(0 To 1) As String
For x = x1 To x2
For y = y1 To y2
XYarr(0) = x
XYarr(1) = y
If GetPixel(SelWnd,x, y) = color Then
ColorSearch.x = x
ColorSearch.y = y
Exit Function
End If
Next y
Next x
End Function

Or use this one.:

Public Function FindColor(window As Long, ColorToFind As Long)
Dim x As Long, y As Long, Test As Long, WndRECT As RECT
GetWindowRect window, WndRECT
Test = GetDC(window)
For y = 0 To (WndRECT.Bottom - WndRECT.Top)
For x = 0 To (WndRECT.Right - WndRECT.Left)
If GetPixel(Test, x, y) = ColorToFind Then
SetCursorPos x + WndRECT.Left, y + WndRECT.Top
Exit Function
End If
Next x
Next y
End Function



Declarations:

Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long

Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As Long

Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long

Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type


Cruel__Machine
Senior Member


Jan 2, 2006, 5:04 AM

Post #3 of 17 (493 views)
Shortcut
Re: [terrankiller] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post

^^Ya.

And if you must search through large areas (like 330x600 or something) Then just make sure you use DoEvents wisely as to make it find the color quickly, but still not FREEze-up your app.


EOP
___________________________
"If evolution were true, I'd have a self-lubricating hand."

Programmers: http://Cruels.net


brownhead
Member

Jan 2, 2006, 12:48 PM

Post #4 of 17 (484 views)
Shortcut
I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post

Thanks Smile, g'day all, again


-------------------------------------


[img]http://i25.photobucket.com/albums/c51/70k0/BHU.png[/img]


Cruel__Machine
Senior Member


Jan 8, 2006, 4:38 PM

Post #5 of 17 (472 views)
Shortcut
Re: [brownhead] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post

Made a DLL in delphi now. :)

I tested it a little bit... but no one else yet. This is going to be my DLL with autoing functions. I will try to include most of the useful functions of SCAR in it.

I searched a 700x700 block almost instantly (around 15 ms I think...) while the regular looping method above took about 2 seconds.


EOP
___________________________
"If evolution were true, I'd have a self-lubricating hand."

Programmers: http://Cruels.net

(This post was edited by Cruel__Machine on Jan 8, 2006, 4:40 PM)


thechezman14
Enthusiast


Jan 8, 2006, 11:35 PM

Post #6 of 17 (468 views)
Shortcut
Re: [Cruel__Machine] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post


In Reply To
Made a DLL in delphi now. :)

I tested it a little bit... but no one else yet. This is going to be my DLL with autoing functions. I will try to include most of the useful functions of SCAR in it.

I searched a 700x700 block almost instantly (around 15 ms I think...) while the regular looping method above took about 2 seconds.

you bloody legend, you never fail to impress me m8



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
will MM for FREE

This is 10% luck, 20% skill, 15% concentrated power of will, 5% pleasure, 50% pain, And a 100% reason to remember the name - mike shinoda


terrankiller
Veteran


Jan 9, 2006, 5:40 AM

Post #7 of 17 (465 views)
Shortcut
Re: [Cruel__Machine] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post

I know where you live tom, in my area. And when your asleep, we are going to raid your house and steal your source. And all your source will belong to us. Is the 3rd storm going to hit sometime this week?


thechezman14
Enthusiast


Jan 9, 2006, 4:07 PM

Post #8 of 17 (458 views)
Shortcut
Re: [terrankiller] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post

LaughLaughLaughis that cruels's real name, tomLaughLaughLaugh



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
will MM for FREE

This is 10% luck, 20% skill, 15% concentrated power of will, 5% pleasure, 50% pain, And a 100% reason to remember the name - mike shinoda


brownhead
Member

Jan 9, 2006, 8:03 PM

Post #9 of 17 (457 views)
Shortcut
Re: [Cruel__Machine] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post


In Reply To
Made a DLL in delphi now. :)

I tested it a little bit... but no one else yet. This is going to be my DLL with autoing functions. I will try to include most of the useful functions of SCAR in it.

I searched a 700x700 block almost instantly (around 15 ms I think...) while the regular looping method above took about 2 seconds.



I'm not worthy!! *kneels* Laugh


-------------------------------------


[img]http://i25.photobucket.com/albums/c51/70k0/BHU.png[/img]


Cruel__Machine
Senior Member


Jan 10, 2006, 9:57 AM

Post #10 of 17 (452 views)
Shortcut
Re: [thechezman14] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post


In Reply To
LaughLaughLaughis that cruels's real name, tomLaughLaughLaugh

Yup.
And here's all my info: http://www.whois.sc/cruels.net

Now you know where I live and my phone number (which actually doesn't work anymore... I don't have phone service... just my cell now.

Here's a smaple project of the DLL if you wish to see the great results ;)
http://cruels.net/downloads/dll_test.zip

Press the first button to set a black pixel in the bottom right of the picture box.
Then press the next two buttons to see the two different methods.

This is just an example.. I wouldn't actually use it considering I'll be releasing a DLL with tons more on it later.

BTW, don't press the "array" button or whatever... unless you wish to crash the app.


EOP
___________________________
"If evolution were true, I'd have a self-lubricating hand."

Programmers: http://Cruels.net


thechezman14
Enthusiast


Jan 10, 2006, 12:37 PM

Post #11 of 17 (449 views)
Shortcut
Re: [Cruel__Machine] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post

ok tom



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
will MM for FREE

This is 10% luck, 20% skill, 15% concentrated power of will, 5% pleasure, 50% pain, And a 100% reason to remember the name - mike shinoda


brownhead
Member

Jan 10, 2006, 1:18 PM

Post #12 of 17 (445 views)
Shortcut
Re: [Cruel__Machine] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post

*boggle* That is amazing! Heluva lot faster than any other function I've seen. Great Job Cruel! Sly

BTW, whats the compiler for Delphi and anybody wanna tell me where to get it? (I'm really hoping its FREETongue)


-------------------------------------


[img]http://i25.photobucket.com/albums/c51/70k0/BHU.png[/img]

(This post was edited by brownhead on Jan 10, 2006, 1:21 PM)


Cruel__Machine
Senior Member


Jan 10, 2006, 1:33 PM

Post #13 of 17 (439 views)
Shortcut
Re: [brownhead] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post

Not FREE. :(
You could make the same with C++ though :P


EOP
___________________________
"If evolution were true, I'd have a self-lubricating hand."

Programmers: http://Cruels.net


brownhead
Member

Jan 10, 2006, 2:05 PM

Post #14 of 17 (437 views)
Shortcut
Re: [Cruel__Machine] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post


In Reply To
Not FREE. :(
You could make the same with C++ though :P



Damit. All well, guess I'll stick with VB, thanks for the answer Smile

Rest of the post moved to a full thread of its own. (Rate my Encryption)


-------------------------------------


[img]http://i25.photobucket.com/albums/c51/70k0/BHU.png[/img]

(This post was edited by brownhead on Jan 10, 2006, 2:50 PM)


terrankiller
Veteran


Jan 11, 2006, 12:25 PM

Post #15 of 17 (432 views)
Shortcut
Re: [Cruel__Machine] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post

I'm going to start learning delphi soon. Sythe tells me delphi is way better than vb. So I'm taking his word for it and trying it out. Btw cruel, I used your smoothmouseex function in my autominer. Works like a charm, you got credits in my autominer ;).


Cruel__Machine
Senior Member


Jan 12, 2006, 11:16 AM

Post #16 of 17 (424 views)
Shortcut
Re: [terrankiller] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post

Heh.

You use my code to move the mouse like someone on crack?


EOP
___________________________
"If evolution were true, I'd have a self-lubricating hand."

Programmers: http://Cruels.net


terrankiller
Veteran


Jan 12, 2006, 11:45 AM

Post #17 of 17 (422 views)
Shortcut
Re: [Cruel__Machine] I'm trying to figure out how to locate a color on the users screen, can anybody help? [In reply to] Can't Post

Lawl, that would be a good prank. Unfortunatly no.

 
 
 


Search for (options) Web Design by Web Ideas - Page loaded in: 0.23 s on (CGI/1.1)