kaiwa...@unlv.edu wrote:
> I use the code to get screen size by perl in windows system:
> $size=`wmic DESKTOPMONITOR get screenwidth,screenheight`;
This is a call to a Windows utility - with the backticks
you make perl execute that command and store the returned
string in the '$size' variable.
I don't know what this Windows uility returns, I just
can guess that it's the width and height in pixels of
the screen.
> But this code cannot get the screen size in Unix system. How to get screen
> size by perl in any operation system?
There is none. The problem starts with that there is no
necessity that there's a screen at all. This is rather
unlikely to happen under Windows but, for example, many
Unix servers don't even have a graphics card (and no
keyboard or mouse either) - you log into them using e.g.
ssh and input and output is done via a remote terminal.
On the other hand, there are machines with more than one
monitor, which can be managed to appear as a single
"screen", but also as several ones. For whch of those
do you want the screen size?
If you're on a Unix machine that has a monitor and has
the X Windows system runnig (which is not always the
case, some may just have a console, i.e. a kind of
terminal). then, as 'T' pointed out, the information
about the screen dimensions can be obtained with the
'xdpyinfo' utility. Its output has a line with the
dimensions for each screen attached. But also that in-
formation might be a bit off if someone is using
'xrandr' to rotate the screen...
And then there are other operating systems...
If you write a a program that uses graphics (and otherwise,
why would you need to know about the screen size?) you're
rather likely be using some module for doing the graphics
stuff. And the best bet is that this module has some func-
tion that lets you ask for the screen size in a system-
independent way.
Regards, Jens
--
\ Jens Thoms Toerring ___
j...@toerring.de
\__________________________
http://toerring.de