|
本帖最后由 清泉石上流shm 于 2013-6-14 19:35 编辑
各位版主,EXCEL前面,强人们:
大家下午好!如题给定一个屏幕坐标,想获取该坐标点的RGB值,请会的大侠们帮帮忙!!{:soso_e183:}
以下是网上获得的VB6.0中的程序,但是我放到EXCEL宏编辑器里编译就出现了错了,请大侠们参考,帮我在EXCEL可以实现,谢谢!
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
以下还有百度文库的VB6.0获取的方法,也不是EXCEL中的,
http://wenku.baidu.com/view/badb3fa0b0717fd5360cdc22.html
请参看,能不能在EXCEL中也能实现,谢谢!!
|
|