codice:
Option Explicit

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 GetAsyncKeyState Lib "user32" _
    (ByVal vKey As Long) As Integer
    
Private Declare Function GetWindowDC Lib "user32" _
    (ByVal hwnd As Long) As Long
    
Private Type POINTAPI
        x As Long
        y As Long
End Type


Private Sub Command1_Click()
Dim pos As POINTAPI
Dim lDC As Long
mainLoop:
    If GetAsyncKeyState(vbKeyReturn) < 0 Then 'premi enter scivi il colore
        lDC = GetWindowDC(0)
        Call GetCursorPos(pos)
        Debug.Print GetPixel(lDC, pos.x, pos.y)
    ElseIf GetAsyncKeyState(vbKeyEscape) < 0 Then 'premi esc esci
        End
    End If
    DoEvents
    GoTo mainLoop
End Sub