

Veremos nesta dica como fazer um código em VBA puro, mas com base em funções do aplicativo do Windows. Este código provavelmente terá que ser adaptado para versões de 64 bits.
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
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 Declare Function GetWindowDC Lib "USER32" (ByVal hWnd As Long) As Long
Sub Color_of_a_screen_pixel()
Debug.Print Gcolor
End Sub
Function Gcolor() As Long
Dim P As POINTAPI, L As Long
L = GetWindowDC(0)
GetCursorPos P
Gcolor = GetPixel(L, P.x, P.y)
End Function
Foto: © VBA.