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 over old one #or send error $img=Imager->new(); #make new image $img->read(file=>'screenshot.png',type=>'png'); #read from fresh screenshot $color = $img->getpixel(x=>68, y=>58); #get pixel from coordinate 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 compare element from $keys = (22); #3. the same coordinates, 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 $keys SendKeys ($keys, 100) } sleep 1; #sleep for one sec goto START; #go back and do compare again with new screenshot