Monday, May 5, 2008

Monitor resolution test using perl

dccmd.exe is a tool which gives all supported resolutions of a monitor.
Download Location:
http://www.softpedia.com/get/System/OS-Enhancements/ResChange.shtml

If somebody wants to write a script to test
the graphics or resolutions supported by the Monitor
we can write a basic perl script as below:

#!c:\Perl\bin\perl.exe
#use Strict;
#use warnings;

# Find all posible resolutions supported by the used monitor
# And capture the command output.
open(SYSCMD, "dccmd -listmodes |");

while()
{
if(/(\d+)[\s+](.*)$/)
{
chomp;
push(@X_Cord, $1);
}
if(/[\s+](\d+)(\s+)(.*)$/)
{
chomp;
push(@Y_Cord, $1);

}
if(/[\s+](\d+)(\s+)(\d+)$/)
{
chomp;
push(@depth, $1);

}
if(/[\s+](\d+)$/)
{
chomp;
push(@refresh, $1);

}

}
close(SYSCMD);

# Put all supported resolutions in arrays
# And count any one arrays length.

$Count = @X_Cord;

# Use dccmd tool to run any utility of test
# in all posible resolutions
# For example I am running
# a movie using media player classic
# Once the movie will be over in one particular resolution,
# it will come back to original resolution
# and again go back to next resolution
# and run the movie again

for ($i=0; $i <= $Count; $i++)
{
`dccmd -force -width=$X_Cord[$i] -height=$Y_Cord[$i] -depth=$depth[$i] -refresh=$refresh[$i] mplayerc.exe /play pursuit_of_happiness.avi /close /fullscreen`;
}