VB6 获取屏幕上某点的颜色
获取屏幕(桌面,非窗体)上某点的颜色那一点不是鼠标所在的点,而是窗体左上角上的一点:X=ME.LEFT-15Y=ME.TOP-15用API,颜色值为RGB(R_,G_,B...
获取屏幕(桌面,非窗体)上某点的颜色
那一点不是鼠标所在的点,而是窗体左上角上的一点:
X=ME.LEFT-15
Y=ME.TOP-15
用API,颜色值为RGB(R_,G_,B_)'[不用帮我显示出来了;看好了,有"_"]
用API获取分别代入R_、G_、B_
希望是原创的。
乐于助人,帮人帮己。 展开
那一点不是鼠标所在的点,而是窗体左上角上的一点:
X=ME.LEFT-15
Y=ME.TOP-15
用API,颜色值为RGB(R_,G_,B_)'[不用帮我显示出来了;看好了,有"_"]
用API获取分别代入R_、G_、B_
希望是原创的。
乐于助人,帮人帮己。 展开
1个回答
展开全部
Private Declare Function GetDC 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 Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Sub Command1_Click()'手动获得
AutoRedraw = True
Dim P As POINTAPI
Dc = GetDC(0)
GetCursorPos P
Me.BackColor = GetPixel(Dc, -15, -15)'获得坐标点颜色
'如果非要用RGB格式,可以这样
'Me.BackColor = RGB("&H" & Right(Hex(GetPixel(Dc, -15, -15)), 2), "&H" & Right(Left(Hex(GetPixel(Dc, -15, -15)), 4), 2), "&H" & Left(Hex(GetPixel(Dc, -15, -15)), 2))
'下面是跟踪鼠标坐标的颜色
'Me.Caption = Hex(GetPixel(Dc, P.X, P.Y))
'Me.BackColor = RGB("&H" & Right(Hex(GetPixel(Dc, P.X, P.Y)), 2), "&H" & Right(Left(Hex(GetPixel(Dc, P.X, P.Y)), 4), 2), "&H" & Left(Hex(GetPixel(Dc, P.X, P.Y)), 2))
End Sub
Private Sub Timer1_Timer()'这个定时器可以自动获得
Private Sub Command1_Click()
End Sub
Private Declare Function GetPixel Lib "gdi32" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Sub Command1_Click()'手动获得
AutoRedraw = True
Dim P As POINTAPI
Dc = GetDC(0)
GetCursorPos P
Me.BackColor = GetPixel(Dc, -15, -15)'获得坐标点颜色
'如果非要用RGB格式,可以这样
'Me.BackColor = RGB("&H" & Right(Hex(GetPixel(Dc, -15, -15)), 2), "&H" & Right(Left(Hex(GetPixel(Dc, -15, -15)), 4), 2), "&H" & Left(Hex(GetPixel(Dc, -15, -15)), 2))
'下面是跟踪鼠标坐标的颜色
'Me.Caption = Hex(GetPixel(Dc, P.X, P.Y))
'Me.BackColor = RGB("&H" & Right(Hex(GetPixel(Dc, P.X, P.Y)), 2), "&H" & Right(Left(Hex(GetPixel(Dc, P.X, P.Y)), 4), 2), "&H" & Left(Hex(GetPixel(Dc, P.X, P.Y)), 2))
End Sub
Private Sub Timer1_Timer()'这个定时器可以自动获得
Private Sub Command1_Click()
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询