I'm trying to expand my knowledge of the Windows API. Why? I'm the curious type and I like a good challenge. So I went ahead and read the docs and came up with this.
#!/usr/bin/perl use strict; use warnings; use Win32::API; #Private Declare Function GetDC Lib "user32" (ByVal hWnd As Long) As L +ong Win32::API->Import( 'user32', 'long GetDC(long hWnd)', ); #Declare Function GetPixel Lib "gdi32" Alias "GetPixel" (ByVal hdc As +Long, ByVal x As Long, ByVal y As Long) As Long Win32::API->Import( 'gdi32', 'long GetPixel(long hdc, long x, long y)', ); sub PixelColor { my ($x, $y) = @_; my $dc = GetDC(''); my $rgb = sprintf "%06x", GetPixel(GetDC(''), $x, $y); return $rgb; } print PixelColor(100, 100), "\n";
Update: Changed "%x" to "%06x".
In reply to Re: Detect Pixel Color on WinXP
by Mr. Muskrat
in thread Detect Pixel Color on WinXP
by kesterkester
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |