VB Code:
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetWindowDC Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) 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 SetCursorPos Lib "user32" (ByVal X As Long, ByVal Y As Long) As Long
Private Declare Function ShowCursor Lib "user32" (ByVal bShow As Long) As Long
Private X As Single
Private Y As Single
Private Sub Form_Load()
Timer1.Enabled = True
ShowCursor 0
X = 50
Y = 500
End Sub
Private Sub Form_Unload(Cancel As Integer)
ShowCursor 1
End Sub
Private Sub Timer1_Timer()
Dim dc As Long, pt As POINTAPI
X = X + 1
Y = Y + 1
If X = 300 Then Unload Me
SetCursorPos X, Y
GetCursorPos pt
dc = GetWindowDC(0)
colour = GetPixel(dc, pt.X, pt.Y)
Me.BackColor = colour
End Sub