一个类似矩形的列阵
格式为5*4
整个表格有20个格子.行5,列4
而我要判断每一个格子里面的东西.由于是一个表格.内存不好找.又不能编辑.
只好采用了getpixel来判断,但是每一种花的都要好几个样式.我每个写一次..快累死了
有没有什么好的算法.望高手帮忙一下.以下是小弟写对一个花的判断..
现在已经写了8种花了..还剩下30几种..已经累积了3个模块了..我要算法..我要算法!!高手帮帮忙!dim qsh as long '七色花Public Function Color(x, y) As Long
dc = GetDC(FindWindow(vbNullString,"失灵齐药"))
Color = GetPixel(dc, x, y)
ReleaseDC 0, dc
End Function
Public Sub 七色花()
If Color(311, 144) = 15709819 Then '七色花1格
If Color(334, 144) = 11926404 Then
If Color(311, 175) = 5950463 Then
qsh = 1
End If
End If
End If
If Color(364, 144) = 15709819 Then '七色花2格
If Color(387, 144) = 11926404 Then
If Color(364, 175) = 5950463 Then
qsh = 2
End If
End If
End If
If Color(417, 144) = 15709819 Then '七色花3格
If Color(440, 144) = 11926404 Then
If Color(417, 175) = 5950463 Then
qsh = 3
End If
End If
End If
If Color(470, 144) = 15709819 Then '七色花4格
If Color(493, 144) = 11926404 Then
If Color(470, 175) = 5950463 Then
qsh = 4
End If
End If
End If
If Color(523, 144) = 15709819 Then '七色花5格
If Color(546, 144) = 11926404 Then
If Color(523, 175) = 5950463 Then
qsh = 5
End If
End If
End If
'-----------------------------------------------------------
If Color(311, 197) = 15709819 Then '七色花6格
If Color(334, 197) = 11926404 Then
If Color(311, 228) = 5950463 Then
qsh = 6
End If
End If
End If
If Color(364, 197) = 15709819 Then '七色花7格
If Color(387, 197) = 11926404 Then
If Color(364, 228) = 5950463 Then
qsh = 7
End If
End If
End If
If Color(417, 197) = 15709819 Then '七色花8格
If Color(440, 197) = 11926404 Then
If Color(417, 228) = 5950463 Then
qsh = 8
End If
End If
End If
If Color(470, 197) = 15709819 Then '七色花9格
If Color(493, 197) = 11926404 Then
If Color(470, 228) = 5950463 Then
qsh = 9
End If
End If
End If
If Color(523, 197) = 15709819 Then '七色花10格
If Color(546, 197) = 11926404 Then
If Color(523, 228) = 5950463 Then
qsh = 10
End If
End If
End If
'-----------------------------------------------------------
If Color(311, 250) = 15709819 Then '七色花11格
If Color(334, 250) = 11926404 Then
If Color(311, 281) = 5950463 Then
qsh = 11
End If
End If
End If
If Color(364, 250) = 15709819 Then '七色花12格
If Color(387, 250) = 11926404 Then
If Color(364, 281) = 5950463 Then
qsh = 12
End If
End If
End If
If Color(417, 250) = 15709819 Then '七色花13格
If Color(440, 250) = 11926404 Then
If Color(417, 281) = 5950463 Then
qsh = 13
End If
End If
End If
If Color(470, 250) = 15709819 Then '七色花14格
If Color(493, 250) = 11926404 Then
If Color(470, 281) = 5950463 Then
qsh = 14
End If
End If
End If
If Color(523, 250) = 15709819 Then '七色花15格
If Color(546, 250) = 11926404 Then
If Color(523, 281) = 5950463 Then
qsh = 15
End If
End If
End If
'-----------------------------------------------------------
If Color(311, 303) = 15709819 Then '七色花16格
If Color(334, 303) = 11926404 Then
If Color(311, 334) = 5950463 Then
qsh = 16
End If
End If
End If
If Color(364, 303) = 15709819 Then '七色花17格
If Color(387, 303) = 11926404 Then
If Color(364, 334) = 5950463 Then
qsh = 17
End If
End If
End If
If Color(417, 303) = 15709819 Then '七色花18格
If Color(440, 303) = 11926404 Then
If Color(417, 334) = 5950463 Then
qsh = 18
End If
End If
End If
If Color(470, 303) = 15709819 Then '七色花19格
If Color(493, 303) = 11926404 Then
If Color(470, 334) = 5950463 Then
qsh = 19
End If
End If
End If
If Color(523, 303) = 15709819 Then '七色花20格
If Color(546, 303) = 11926404 Then
If Color(523, 334) = 5950463 Then
qsh = 20
End If
End If
End If
End Function

解决方案 »

  1.   

    忘了说一下.
    每个表格之间的距离是53
    也就是Left+53 和top+53就是第2个表格
      

  2.   

    你要是这种情况的话把特征坐标和特征值写到数据库里算了
    SQL可以出来嘛,别改代码了,要改就改数据库就好了
      

  3.   

    换方法了 .
    这个代码实在是,,  最起码你要把这个"颜色"定义成变量才对吧.If Color(523, 303) = 15709819 Then '七色花20格
    If Color(546, 303) = 11926404 Then
    If Color(523, 334) = 5950463 Then
    qsh = 20
    End If
    End If
    End If
    最起码这要做成一个函数吧.做外挂吧, 这个qsh我认为是可以从内存中取的.
      

  4.   

    恩。是要判断一个格子的颜色值
    pigsanddogs(我爱吃猪肉,但是长不胖,为什么??)
    每个药品的颜色都不一样的。
    不然我都是设置成变量了现在就是要把所有药品全部写下来。很费时间。
    想搞个算法。
    Hassle() 
    你说导入数据库。
    我对这方面不了解。呵呵..给个算法就行拉`~