VB 指定窗口抓色抓坐标,再判断
例如:我现在有某个窗口的相对坐标(231523)和那个坐标的颜色值(FFFFFF),但那个坐标的颜色是会不断变化的。我想用VB来不断检测那个坐标的颜色,当颜色发生变化时,...
例如:我现在有某个窗口的相对坐标(231 523)和那个坐标的颜色值(FFFFFF),但那个坐标的颜色是会不断变化的。我想用VB来不断检测那个坐标的颜色,当颜色发生变化时,执行一段代码。
注:一定要是某个窗体内的坐标和颜色,不是VB程序的窗体哦。
有会的请详细的教下怎样做。谢谢了。 展开
注:一定要是某个窗体内的坐标和颜色,不是VB程序的窗体哦。
有会的请详细的教下怎样做。谢谢了。 展开
2个回答
展开全部
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Sub Command1_Click()
Dim hwndSrc As Long, hSrcDC As Long
Dim c As Long
Dim x As Long, y As Long
x = 231
y = 523
hwndSrc = 赋值要抓取的窗体句柄
hSrcDC = GetDC(hwndSrc)'如果包括边框的全窗口 就用 GetWindowDC
c = GetPixel(hSrcDC, x, y)
ReleaseDC hwndSrc, hSrcDC
End Sub
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long
Private Sub Command1_Click()
Dim hwndSrc As Long, hSrcDC As Long
Dim c As Long
Dim x As Long, y As Long
x = 231
y = 523
hwndSrc = 赋值要抓取的窗体句柄
hSrcDC = GetDC(hwndSrc)'如果包括边框的全窗口 就用 GetWindowDC
c = GetPixel(hSrcDC, x, y)
ReleaseDC hwndSrc, hSrcDC
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询