如何监控屏幕上的某个点的颜色是否发生变化,如果这个点变化的比较快的话,怎样才能保证不漏检?
Form
Private Sub Command1_Click()
actTime1 = GetTickCount
lTimeID = timeSetEvent(10, 0, AddressOf TimeProc, 1, 1)
End Sub
Private Sub Command2_Click()
EndCount
End Sub
模块
Sub TimeProc(ByVal uID As Long, ByVal uMsg As Long, ByVal dwUser As Long, ByVal dw1 As Long, ByVal dw2 As Long)
AimColor = getColor(X(i), Y(i))
If AimColor <> Color(i) Then
mouseClick aimX(i), aimY(i)
i = i + 1
End If
End Sub
Sub EndCount()
timeKillEvent lTimeID
actTime2 = GetTickCount - actTime1
End Sub
Public Function getColor(ByVal newX As Long, ByVal newY As Long) As Long
Dim windowDC As Long
windowDC = GetWindowDC(g_WindowHwnd)
getColor = GetPixel(windowDC, newX, newY)
ReleaseDC g_WindowHwnd, windowDC
End Function
Public Sub mouseClick(ByVal X As Long, ByVal Y As Long)
Dim po As POINTAPI
GetCursorPos po
mouse_event MOUSEEVENTF_MOVE Or MOUSEEVENTF_ABSOLUTE, X * 65535 / 1024, Y * 65535 / 768, 0&, 0&
mouse_event MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_LEFTUP Or MOUSEEVENTF_ABSOLUTE, 0, 0, 0&, 0&
SetCursorPos po.X, po.Y
End Sub
这是我的代码的一部分,不知道有什么问题,老是非法操作。