hi all i got a question, i tried lots of things but i cant find any answers. how can i compare a picture in a picture box with something on the screen at given coordinates, im looking for something like this:
VB Code:
Option Explicit
Public Sub CompareIMG()
Dim intX As Integer
Dim intY As Integer
Dim blnMatch As Boolean 'True if pictures match
If intX > 200 Then 'Check within given coordinates
intX = 0
intY = intY + 1
Else
Do Until blnMatch = True
'Here is what i dont get, i hope it will be short like this:
Compare picImage With (intX, intY), blnMatch
intX = intX + 1
Loop
End If
End Sub
but it will probably will be very different
I hope anyone knows how to do something like this
If you have a good look at the code you will notice the comment "'Compare the Colors of Each Byte". This is the loop which compares the two images byte by byte, so no it's not just comparing file sizes
i remember i could do something i wanted with colors, it made a spiral from the middle of the screen untill it finds the color. i was thinking of something sort like. i shall add a crappy bit of code, its very old from the time when i couldnt really program. here it is:
VB Code:
On Error Resume Next
Righto = False
DoCheck
DoEvents
If Righto = True Then Exit Sub
Dim i
For i = 1 To Outwards
BigX = BigX + 4
lilX = lilX + 4
DoCheck
DoEvents
If Righto = True Then Exit Sub
Next
For i = 1 To Outwards
BigY = BigY + 4
lilY = lilY + 4
DoCheck
DoEvents
If Righto = True Then Exit Sub
Next
Outwards = Outwards + 2
For i = 1 To Outwards
BigX = BigX - 4
lilX = lilX - 4
DoCheck
DoEvents
If Righto = True Then Exit Sub
Next
For i = 1 To Outwards
BigY = BigY - 4
lilY = lilY - 4
DoCheck
DoEvents
If Righto = True Then Exit Sub
Next
Outwards = Outwards + 2
If Outwards > 70 Then
BigX = closeX
BigY = closeY
lilY = Sample.Height \ 2
lilX = Sample.Width \ 2
Outwards = 0
Picture1.Cls
End If
pretty crappy huh? it needs some coding to be done but it might be useful.
if i used that it will really take ages, because i have to compare over 10,000 images (257x42) but i still do have a question,if i make a screenshot, there is more on the picture then i want. i just want to compare a small piece of the screenshot with my pictures. how can i do something like this?
Tec-Nico your Piccomp app works great with bmp, gif, jpg etc. But if you load icons into the images you get Subscript out of range in:
ReDim Bytes1(0 To Bm1.bmWidthBytes - 1, 0 To Bm1.bmHeight - 1)
Because it can't dimension the array. Any ideas why it can't find the height and width.
Keith
I've been programming with VB for 25 years. Started with VB4 16bit Pro, VB5 Pro, VB6 Pro/Enterprise and now VB3 Pro. But I'm no expert, I'm still learning.