#Private Declare Function ReleaseDC Lib "user32" (ByVal hWnd As Long, ByVal hDC As Long) As Long Win32::API->Import( 'user32', 'long ReleaseDC(long hWnd, long hDC)', ); #Private Declare Function GetDesktopWindow Lib "user32" () As Long Win32::API->Import( 'user32', 'long GetDesktopWindow()', ); sub PixelColor { my ($hwnd, $x, $y) = @_; my $dc = GetDC($hwnd); my $rgb = GetPixel($dc, $x, $y); ReleaseDC($hwnd, $dc); return $rgb < 0 ? undef: sprintf "%06x", $rgb; } print PixelColor(GetDesktopWindow(), 100, 100);