in reply to How to get pixel color from 3d application
use Imager; use Imager::Screenshot 'screenshot'; use Win32::GuiTest qw(FindWindowLike GetWindowText SetForegroundWindow SendKeys); START: my $img = screenshot(); #make screenshot $img->write(file => 'screenshot.png', type => 'png' ) || print "Failed: ", $img->{ERRSTR} , "\n"; #write a new sreenshot o +ver old one #or send error $img=Imager->new(); #make new image $img->read(file=>'screenshot.png',type=>'png'); #read from fresh scre +enshot $color = $img->getpixel(x=>68, y=>58); #get pixel from coord +inate x,y $img1=Imager->new(); #make new image $img1->read(file=>'orginal.png',type=>'png'); #1.read from orginal +pcitrue i have made $color1 = $img1->getpixel(x=>68, y=>58); #2. before to compar +e element from $keys = (22); #3. the same coordina +tes, so when #4. window is change +on any diferent color #5. program show doin + code (else) if ($color->equals(other=>$color1)) { #if color is the same print "ok\n" #print ok, do nothing. } else { #else press key 22 from $key +s SendKeys ($keys, 100) } sleep 1; #sleep for one sec goto START; #go back and do compare aga +in with new screenshot
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to get pixel color from 3d application
by tonyc (Friar) on Mar 01, 2016 at 22:32 UTC | |
by JuR (Initiate) on Mar 02, 2016 at 04:22 UTC |