I am trying to get figures to automatically pop-up on the
second monitor that is attached to my computer. Based on
previous forum topics, I see that using get
(0, "screensize') has been suggested as a way to find the
position of the screen and then use this information to
place the figure. However, when I go this, the output is:
1 1 1024 768.
My first monitor is 1024x768 and my second monitor is
1680x1050. So it appears that the get command is only
processing the first screen.
On Jun 26, 11:51 am, "Jessica " <jyorzin...@ucdavis.edu> wrote:
> Hi,
>
> I am trying to get figures to automatically pop-up on the
> second monitor that is attached to my computer. Based on
> previous forum topics, I see that using get
> (0, "screensize') has been suggested as a way to find the
> position of the screen and then use this information to
> place the figure. However, when I go this, the output is:
>
> 1 1 1024 768.
>
> My first monitor is 1024x768 and my second monitor is
> 1680x1050. So it appears that the get command is only
> processing the first screen.
>
> Does anyone have any ideas to get around this?
>
> Thank!
Hi Jessica,
This is something I got from this newsgroup:
When using more than one monitor (e.g. N monitors) the
positions of the different monitors can be obtained with
> mp = get(0, 'MonitorPositions');
mp is a Nx4 array
mp(1,:) is the position of the primary monitor
mp(k,:) is the position of the k-th monitor.
This can be used instead of the screensize property to
adjust things to the size of the different monitors.
Jomar Bueyes <jomarbueyes@hotmail.com> wrote in message
<01064b4f-5b94-41ad-bdf6-fd6925e6cd3c@d1g2000hsg.googlegroups.com>...
> On Jun 26, 11:51 am, "Jessica " <jyorzin...@ucdavis.edu>
wrote:
> > Hi,
> >
> > I am trying to get figures to automatically pop-up on the
> > second monitor that is attached to my computer. Based on
> > previous forum topics, I see that using get
> > (0, "screensize') has been suggested as a way to find the
> > position of the screen and then use this information to
> > place the figure. However, when I go this, the output is:
> >
> > 1 1 1024 768.
> >
> > My first monitor is 1024x768 and my second monitor is
> > 1680x1050. So it appears that the get command is only
> > processing the first screen.
> >
> > Does anyone have any ideas to get around this?
> >
> > Thank!
>
> Hi Jessica,
>
> This is something I got from this newsgroup:
>
> When using more than one monitor (e.g. N monitors) the
> positions of the different monitors can be obtained with
>
> > mp = get(0, 'MonitorPositions');
>
> mp is a Nx4 array
> mp(1,:) is the position of the primary monitor
> mp(k,:) is the position of the k-th monitor.
>
> This can be used instead of the screensize property to
> adjust things to the size of the different monitors.
>
> HTH
>
> Jomar
When I use this command, matlab outputs:
1 1 1024 768
-1679 -279 0 770
It seems that 279+770 is close to the resolution of my
second monitor height.
Given this, do you know how I can make an image appear on
that second monitor?
I have both imshow and inputdlg commands that pop-up images
and boxes, respectively. Can I add something to these
commands to make them automatically appear on the second screen?
On Jun 26, 12:40 pm, "Jessica " <jyorzin...@ucdavis.edu> wrote:
> Jomar Bueyes <jomarbue...@hotmail.com> wrote in message
>
> <01064b4f-5b94-41ad-bdf6-fd6925e6c...@d1g2000hsg.googlegroups.com>...
>
>
>
> > On Jun 26, 11:51 am, "Jessica " <jyorzin...@ucdavis.edu>
> wrote:
> > > Hi,
>
> > > I am trying to get figures to automatically pop-up on the
> > > second monitor that is attached to my computer. Based on
> > > previous forum topics, I see that using get
> > > (0, "screensize') has been suggested as a way to find the
> > > position of the screen and then use this information to
> > > place the figure. However, when I go this, the output is:
>
> > > 1 1 1024 768.
>
> > > My first monitor is 1024x768 and my second monitor is
> > > 1680x1050. So it appears that the get command is only
> > > processing the first screen.
>
> > > Does anyone have any ideas to get around this?
>
> > > Thank!
>
> > Hi Jessica,
>
> > This is something I got from this newsgroup:
>
> > When using more than one monitor (e.g. N monitors) the
> > positions of the different monitors can be obtained with
>
> > > mp = get(0, 'MonitorPositions');
>
> > mp is a Nx4 array
> > mp(1,:) is the position of the primary monitor
> > mp(k,:) is the position of the k-th monitor.
>
> > This can be used instead of the screensize property to
> > adjust things to the size of the different monitors.
>
> > HTH
>
> > Jomar
>
> When I use this command, matlab outputs:
> 1 1 1024 768
> -1679 -279 0 770
>
> It seems that 279+770 is close to the resolution of my
> second monitor height.
>
> Given this, do you know how I can make an image appear on
> that second monitor?
>
> I have both imshow and inputdlg commands that pop-up images
> and boxes, respectively. Can I add something to these
> commands to make them automatically appear on the second screen?
>
> Thanks!
Hi Jessica,
This is only a guess (I haven't tried it), but something like the
following might work
fh = imshow(whatever); % place the image wherever
fp = get(fh, 'position'); % get the position of the image
set (fh, 'position', [-1600 -270 fp(3:4) ]); % move the image to the
second monitor
The idea is to place the figure at a point in the second monitor with
the width and height of the original figure.
In article <g40ka3$ncf$1@fred.mathworks.com>, "Jessica " <jyorzinski@ucdavis.edu> wrote:
> Jomar Bueyes <jomarbueyes@hotmail.com> wrote in message
> <01064b4f-5b94-41ad-bdf6-fd6925e6cd3c@d1g2000hsg.googlegroups.com>...
> > On Jun 26, 11:51 am, "Jessica " <jyorzin...@ucdavis.edu>
> wrote:
> > > Hi,
> > >
> > > I am trying to get figures to automatically pop-up on the
> > > second monitor that is attached to my computer. Based on
> > > previous forum topics, I see that using get
> > > (0, "screensize') has been suggested as a way to find the
> > > position of the screen and then use this information to
> > > place the figure. However, when I go this, the output is:
> > >
> > > 1 1 1024 768.
> > >
> > > My first monitor is 1024x768 and my second monitor is
> > > 1680x1050. So it appears that the get command is only
> > > processing the first screen.
> > >
> > > Does anyone have any ideas to get around this?
> > >
> > > Thank!
> >
> > Hi Jessica,
> >
> > This is something I got from this newsgroup:
> >
> > When using more than one monitor (e.g. N monitors) the
> > positions of the different monitors can be obtained with
> >
> > > mp = get(0, 'MonitorPositions');
> >
> > mp is a Nx4 array
> > mp(1,:) is the position of the primary monitor
> > mp(k,:) is the position of the k-th monitor.
> >
> > This can be used instead of the screensize property to
> > adjust things to the size of the different monitors.
> >
> > HTH
> >
> > Jomar
>
> When I use this command, matlab outputs:
> 1 1 1024 768
> -1679 -279 0 770
>
> It seems that 279+770 is close to the resolution of my
> second monitor height.
>
> Given this, do you know how I can make an image appear on
> that second monitor?
>
> I have both imshow and inputdlg commands that pop-up images
> and boxes, respectively. Can I add something to these
> commands to make them automatically appear on the second screen?
>
> Thanks!
The MonitorPositions property doesn't seem to return useful
information. I have investigated it on both Mac OS X and
Windows. The solution I came up with is this function,
screensize, which returns the proper coordinates of multiple
screens. I plan on submitting it to the FEX when I get a chance,
but give it a try and let me know how it works out. I need to
add some documentation and work out a few minor details.
To use, just run with no arguments (I only have one screen right now):
>> screensize
ans =
1 0 1920 1200
or pass in the screen number whose coordinates you need:
>> screensize(2)
ans =
1 0 1920 1200
If you don't have that many screens it'll still return the
coordinates of the highest-numbered one.
And here's the function (watch for possible wrapped lines):
------------------ screensize.m ---------------------------
function ss_out = screensize(screen_number)
%screensize: return screen coordinates of multiple monitors.
% Version: 1.0, 26 June 2008
% Author: Douglas M. Schwarz
% Email: dmschwarz=ieee*org, dmschwarz=urgrad*rochester*edu
% Real_email = regexprep(Email,{'=','*'},{'@','.'})
persistent ss
if ~isempty(ss)
num_screens = size(ss,1);
if nargin == 0
screen_number = 1:num_screens;
end
screen_index = min(screen_number,num_screens);
ss_out = ss(screen_index,:);
return
end
% Create an invisible figure (required for get(0,'PointerLocation') to work
% correctly on OS X).
fig = figure('Visible','off');
% Get initial location of mouse pointer.
mouse_loc = java.awt.MouseInfo.getPointerInfo.getLocation;
% Create a robot to move mouse pointer.
robot = java.awt.Robot;
% Get Screen Devices array.
sd = java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment.getScreenDevices;
% Initialize screensize array.
num_screens = length(sd);
ss = zeros(num_screens,4);
% Loop over all Screen Devices.
for i = 1:num_screens
% Get coordinate bounds of Screen Device.
bounds = sd(i).getDefaultConfiguration.getBounds;
% Move mouse pointer to lower left corner of this screen and get MATLAB
% coordinates of that point.
robot.mouseMove(bounds.x, bounds.y + bounds.height)
pl_ll = get(0,'PointerLocation');
% Move mouse pointer to upper right corner of this screen and get
% MATLAB coordinates of that point.
robot.mouseMove(bounds.x + bounds.width, bounds.y)
pl_ur = get(0,'PointerLocation');
% Fill in screen size array.
ss(i,:) = [pl_ll, pl_ur - pl_ll];
end
num_screens = size(ss,1);
if nargin == 0
screen_number = 1:num_screens;
end
screen_index = min(screen_number,num_screens);
ss_out = ss(screen_index,:);
% Return mouse pointer to initial location.
robot.mouseMove(mouse_loc.x, mouse_loc.y)
% Delete the figure.
delete(fig)
-----------------------------------------------------------------
--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
Doug Schwarz <see@sig.for.address.edu> wrote in message
<see-7C8CAB.15311726062008@news.motzarella.org>...
> In article <g40ka3$ncf$1@fred.mathworks.com>, "Jessica "
<jyorzinski@ucdavis.edu> wrote:
>
> > Jomar Bueyes <jomarbueyes@hotmail.com> wrote in message
> >
<01064b4f-5b94-41ad-bdf6-fd6925e6cd3c@d1g2000hsg.googlegroups.com>...
> > > On Jun 26, 11:51 am, "Jessica " <jyorzin...@ucdavis.edu>
> > wrote:
> > > > Hi,
> > > >
> > > > I am trying to get figures to automatically pop-up
on the
> > > > second monitor that is attached to my computer. Based on
> > > > previous forum topics, I see that using get
> > > > (0, "screensize') has been suggested as a way to
find the
> > > > position of the screen and then use this information to
> > > > place the figure. However, when I go this, the
output is:
> > > >
> > > > 1 1 1024 768.
> > > >
> > > > My first monitor is 1024x768 and my second monitor is
> > > > 1680x1050. So it appears that the get command is only
> > > > processing the first screen.
> > > >
> > > > Does anyone have any ideas to get around this?
> > > >
> > > > Thank!
> > >
> > > Hi Jessica,
> > >
> > > This is something I got from this newsgroup:
> > >
> > > When using more than one monitor (e.g. N monitors) the
> > > positions of the different monitors can be obtained with
> > >
> > > > mp = get(0, 'MonitorPositions');
> > >
> > > mp is a Nx4 array
> > > mp(1,:) is the position of the primary monitor
> > > mp(k,:) is the position of the k-th monitor.
> > >
> > > This can be used instead of the screensize property to
> > > adjust things to the size of the different monitors.
> > >
> > > HTH
> > >
> > > Jomar
> >
> > When I use this command, matlab outputs:
> > 1 1 1024 768
> > -1679 -279 0 770
> >
> > It seems that 279+770 is close to the resolution of my
> > second monitor height.
> >
> > Given this, do you know how I can make an image appear on
> > that second monitor?
> >
> > I have both imshow and inputdlg commands that pop-up images
> > and boxes, respectively. Can I add something to these
> > commands to make them automatically appear on the second
screen?
> >
> > Thanks!
>
> The MonitorPositions property doesn't seem to return useful
> information. I have investigated it on both Mac OS X and
> Windows. The solution I came up with is this function,
> screensize, which returns the proper coordinates of multiple
> screens. I plan on submitting it to the FEX when I get a
chance,
> but give it a try and let me know how it works out. I
need to
> add some documentation and work out a few minor details.
>
> To use, just run with no arguments (I only have one screen
right now):
>
> >> screensize
> ans =
> 1 0 1920 1200
>
> or pass in the screen number whose coordinates you need:
>
> >> screensize(2)
> ans =
> 1 0 1920 1200
>
> If you don't have that many screens it'll still return the
> coordinates of the highest-numbered one.
>
> And here's the function (watch for possible wrapped lines):
>
>
> ------------------ screensize.m ---------------------------
> function ss_out = screensize(screen_number)
> %screensize: return screen coordinates of multiple monitors.
>
> % Version: 1.0, 26 June 2008
> % Author: Douglas M. Schwarz
> % Email: dmschwarz=ieee*org, dmschwarz=urgrad*rochester*edu
> % Real_email = regexprep(Email,{'=','*'},{'@','.'})
>
>
> persistent ss
> if ~isempty(ss)
> num_screens = size(ss,1);
> if nargin == 0
> screen_number = 1:num_screens;
> end
> screen_index = min(screen_number,num_screens);
> ss_out = ss(screen_index,:);
> return
> end
>
> % Create an invisible figure (required for
get(0,'PointerLocation') to work
> % correctly on OS X).
> fig = figure('Visible','off');
>
> % Get initial location of mouse pointer.
> mouse_loc = java.awt.MouseInfo.getPointerInfo.getLocation;
>
> % Create a robot to move mouse pointer.
> robot = java.awt.Robot;
>
> % Get Screen Devices array.
> sd =
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment.getScreenDevices;
>
> % Initialize screensize array.
> num_screens = length(sd);
> ss = zeros(num_screens,4);
>
> % Loop over all Screen Devices.
> for i = 1:num_screens
> % Get coordinate bounds of Screen Device.
> bounds = sd(i).getDefaultConfiguration.getBounds;
>
> % Move mouse pointer to lower left corner of this
screen and get MATLAB
> % coordinates of that point.
> robot.mouseMove(bounds.x, bounds.y + bounds.height)
> pl_ll = get(0,'PointerLocation');
>
> % Move mouse pointer to upper right corner of this
screen and get
> % MATLAB coordinates of that point.
> robot.mouseMove(bounds.x + bounds.width, bounds.y)
> pl_ur = get(0,'PointerLocation');
>
> % Fill in screen size array.
> ss(i,:) = [pl_ll, pl_ur - pl_ll];
> end
>
> num_screens = size(ss,1);
> if nargin == 0
> screen_number = 1:num_screens;
> end
> screen_index = min(screen_number,num_screens);
> ss_out = ss(screen_index,:);
>
> % Return mouse pointer to initial location.
> robot.mouseMove(mouse_loc.x, mouse_loc.y)
>
> % Delete the figure.
> delete(fig)
>
-----------------------------------------------------------------
>
> --
> Doug Schwarz
> dmschwarz&ieee,org
> Make obvious changes to get real email address.
Thanks for these suggestions. When I run the function, I get
the output:
1 1 1023 767
-1679 -1 1679 1049
I am still not certain how to use these values to have
images and boxes automatically appear at those positions.
When I try: fh=imshow('picture.bmp');set (fh, [-1679 -1
1679 1049]);
I get an error saying that the parameter/value pair
arguments are invalid.
In article <g4307j$a08$1@fred.mathworks.com>,
"Jessica " <jyorzinski@ucdavis.edu> wrote:
> Doug Schwarz <see@sig.for.address.edu> wrote in message
> <see-7C8CAB.15311726062008@news.motzarella.org>...
> > In article <g40ka3$ncf$1@fred.mathworks.com>, "Jessica "
> <jyorzinski@ucdavis.edu> wrote:
> >
> > > Jomar Bueyes <jomarbueyes@hotmail.com> wrote in message
> > >
> <01064b4f-5b94-41ad-bdf6-fd6925e6cd3c@d1g2000hsg.googlegroups.com>...
> > > > On Jun 26, 11:51 am, "Jessica " <jyorzin...@ucdavis.edu>
> > > wrote:
> > > > > Hi,
> > > > >
> > > > > I am trying to get figures to automatically pop-up
> on the
> > > > > second monitor that is attached to my computer. Based on
> > > > > previous forum topics, I see that using get
> > > > > (0, "screensize') has been suggested as a way to
> find the
> > > > > position of the screen and then use this information to
> > > > > place the figure. However, when I go this, the
> output is:
> > > > >
> > > > > 1 1 1024 768.
> > > > >
> > > > > My first monitor is 1024x768 and my second monitor is
> > > > > 1680x1050. So it appears that the get command is only
> > > > > processing the first screen.
[snip]
> Thanks for these suggestions. When I run the function, I get
> the output:
>
> 1 1 1023 767
> -1679 -1 1679 1049
>
> I am still not certain how to use these values to have
> images and boxes automatically appear at those positions.
> When I try: fh=imshow('picture.bmp');set (fh, [-1679 -1
> 1679 1049]);
>
> I get an error saying that the parameter/value pair
> arguments are invalid.
>
> Any other thoughts?
Jessica,
Referring to your original note I see that you want figures to appear on
your second monitor by default and my program only tells you where that
monitor is. The full answer to your question is to set the default
figure position to the appropriate values. Suppose you want your
figures to be 560x420 pixels centered on your second monitor. Put this
line
What you did above is not correct because fh is an image handle and then
you tried to use set incorrectly. You want to set the position of the
figure, not the image.
--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
"Jessica " <jyorzinski@ucdavis.edu> wrote in message
<g4307j$a08$1@fred.mathworks.com>...
> Doug Schwarz <see@sig.for.address.edu> wrote in message
> <see-7C8CAB.15311726062008@news.motzarella.org>...
> > In article <g40ka3$ncf$1@fred.mathworks.com>, "Jessica "
> <jyorzinski@ucdavis.edu> wrote:
> >
> > > Jomar Bueyes <jomarbueyes@hotmail.com> wrote in message
> > >
>
<01064b4f-5b94-41ad-bdf6-fd6925e6cd3c@d1g2000hsg.googlegroups.com>...
> > > > On Jun 26, 11:51 am, "Jessica " <jyorzin...@ucdavis.edu>
> > > wrote:
> > > > > Hi,
> > > > >
> > > > > I am trying to get figures to automatically pop-up
> on the
> > > > > second monitor that is attached to my computer.
Based on
> > > > > previous forum topics, I see that using get
> > > > > (0, "screensize') has been suggested as a way to
> find the
> > > > > position of the screen and then use this
information to
> > > > > place the figure. However, when I go this, the
> output is:
> > > > >
> > > > > 1 1 1024 768.
> > > > >
> > > > > My first monitor is 1024x768 and my second monitor is
> > > > > 1680x1050. So it appears that the get command is only
> > > > > processing the first screen.
> > > > >
> > > > > Does anyone have any ideas to get around this?
> > > > >
> > > > > Thank!
> > > >
> > > > Hi Jessica,
> > > >
> > > > This is something I got from this newsgroup:
> > > >
> > > > When using more than one monitor (e.g. N monitors) the
> > > > positions of the different monitors can be obtained with
> > > >
> > > > > mp = get(0, 'MonitorPositions');
> > > >
> > > > mp is a Nx4 array
> > > > mp(1,:) is the position of the primary monitor
> > > > mp(k,:) is the position of the k-th monitor.
> > > >
> > > > This can be used instead of the screensize property to
> > > > adjust things to the size of the different monitors.
> > > >
> > > > HTH
> > > >
> > > > Jomar
> > >
> > > When I use this command, matlab outputs:
> > > 1 1 1024 768
> > > -1679 -279 0 770
> > >
> > > It seems that 279+770 is close to the resolution of my
> > > second monitor height.
> > >
> > > Given this, do you know how I can make an image appear on
> > > that second monitor?
> > >
> > > I have both imshow and inputdlg commands that pop-up
images
> > > and boxes, respectively. Can I add something to these
> > > commands to make them automatically appear on the second
> screen?
> > >
> > > Thanks!
> >
> > The MonitorPositions property doesn't seem to return useful
> > information. I have investigated it on both Mac OS X and
> > Windows. The solution I came up with is this function,
> > screensize, which returns the proper coordinates of multiple
> > screens. I plan on submitting it to the FEX when I get a
> chance,
> > but give it a try and let me know how it works out. I
> need to
> > add some documentation and work out a few minor details.
> >
> > To use, just run with no arguments (I only have one screen
> right now):
> >
> > >> screensize
> > ans =
> > 1 0 1920 1200
> >
> > or pass in the screen number whose coordinates you need:
> >
> > >> screensize(2)
> > ans =
> > 1 0 1920 1200
> >
> > If you don't have that many screens it'll still return the
> > coordinates of the highest-numbered one.
> >
> > And here's the function (watch for possible wrapped lines):
> >
> >
> > ------------------ screensize.m ---------------------------
> > function ss_out = screensize(screen_number)
> > %screensize: return screen coordinates of multiple monitors.
> >
> > % Version: 1.0, 26 June 2008
> > % Author: Douglas M. Schwarz
> > % Email: dmschwarz=ieee*org,
dmschwarz=urgrad*rochester*edu
> > % Real_email = regexprep(Email,{'=','*'},{'@','.'})
> >
> >
> > persistent ss
> > if ~isempty(ss)
> > num_screens = size(ss,1);
> > if nargin == 0
> > screen_number = 1:num_screens;
> > end
> > screen_index = min(screen_number,num_screens);
> > ss_out = ss(screen_index,:);
> > return
> > end
> >
> > % Create an invisible figure (required for
> get(0,'PointerLocation') to work
> > % correctly on OS X).
> > fig = figure('Visible','off');
> >
> > % Get initial location of mouse pointer.
> > mouse_loc = java.awt.MouseInfo.getPointerInfo.getLocation;
> >
> > % Create a robot to move mouse pointer.
> > robot = java.awt.Robot;
> >
> > % Get Screen Devices array.
> > sd =
>
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment.getScreenDevices;
> >
> > % Initialize screensize array.
> > num_screens = length(sd);
> > ss = zeros(num_screens,4);
> >
> > % Loop over all Screen Devices.
> > for i = 1:num_screens
> > % Get coordinate bounds of Screen Device.
> > bounds = sd(i).getDefaultConfiguration.getBounds;
> >
> > % Move mouse pointer to lower left corner of this
> screen and get MATLAB
> > % coordinates of that point.
> > robot.mouseMove(bounds.x, bounds.y + bounds.height)
> > pl_ll = get(0,'PointerLocation');
> >
> > % Move mouse pointer to upper right corner of this
> screen and get
> > % MATLAB coordinates of that point.
> > robot.mouseMove(bounds.x + bounds.width, bounds.y)
> > pl_ur = get(0,'PointerLocation');
> >
> > % Fill in screen size array.
> > ss(i,:) = [pl_ll, pl_ur - pl_ll];
> > end
> >
> > num_screens = size(ss,1);
> > if nargin == 0
> > screen_number = 1:num_screens;
> > end
> > screen_index = min(screen_number,num_screens);
> > ss_out = ss(screen_index,:);
> >
> > % Return mouse pointer to initial location.
> > robot.mouseMove(mouse_loc.x, mouse_loc.y)
> >
> > % Delete the figure.
> > delete(fig)
> >
>
-----------------------------------------------------------------
> >
> > --
> > Doug Schwarz
> > dmschwarz&ieee,org
> > Make obvious changes to get real email address.
>
>
> Thanks for these suggestions. When I run the function, I get
> the output:
>
> 1 1 1023 767
> -1679 -1 1679 1049
>
> I am still not certain how to use these values to have
> images and boxes automatically appear at those positions.
> When I try: fh=imshow('picture.bmp');set (fh, [-1679 -1
> 1679 1049]);
>
> I get an error saying that the parameter/value pair
> arguments are invalid.
>
> Any other thoughts?
Make sure you identify what parameter you want to set for
fh. Your code above:
set(fh, [-1679 -1 1679 1049]);
doesn't identify a parameter that you're setting -- only the
object. Try this instead:
"Ian Clarkson" <ovoidkumquat@hotmail.com> wrote in message
<g434m2$8bd$1@fred.mathworks.com>...
> "Jessica " <jyorzinski@ucdavis.edu> wrote in message
> <g4307j$a08$1@fred.mathworks.com>...
> > Doug Schwarz <see@sig.for.address.edu> wrote in message
> > <see-7C8CAB.15311726062008@news.motzarella.org>...
> > > In article <g40ka3
$ncf$1@fred.mathworks.com>, "Jessica "
> > <jyorzinski@ucdavis.edu> wrote:
> > >
> > > > Jomar Bueyes <jomarbueyes@hotmail.com> wrote in
message
> > > >
> >
> <01064b4f-5b94-41ad-bdf6-
fd6925e6cd3c@d1g2000hsg.googlegroups.com>...
> > > > > On Jun 26, 11:51 am, "Jessica "
<jyorzin...@ucdavis.edu>
> > > > wrote:
> > > > > > Hi,
> > > > > >
> > > > > > I am trying to get figures to automatically pop-
up
> > on the
> > > > > > second monitor that is attached to my computer.
> Based on
> > > > > > previous forum topics, I see that using get
> > > > > > (0, "screensize') has been suggested as a way to
> > find the
> > > > > > position of the screen and then use this
> information to
> > > > > > place the figure. However, when I go this, the
> > output is:
> > > > > >
> > > > > > 1 1 1024 768.
> > > > > >
> > > > > > My first monitor is 1024x768 and my second
monitor is
> > > > > > 1680x1050. So it appears that the get command
is only
> > > > > > processing the first screen.
> > > > > >
> > > > > > Does anyone have any ideas to get around this?
> > > > > >
> > > > > > Thank!
> > > > >
> > > > > Hi Jessica,
> > > > >
> > > > > This is something I got from this newsgroup:
> > > > >
> > > > > When using more than one monitor (e.g. N
monitors) the
> > > > > positions of the different monitors can be
obtained with
> > > > >
> > > > > > mp = get(0, 'MonitorPositions');
> > > > >
> > > > > mp is a Nx4 array
> > > > > mp(1,:) is the position of the primary monitor
> > > > > mp(k,:) is the position of the k-th monitor.
> > > > >
> > > > > This can be used instead of the screensize
property to
> > > > > adjust things to the size of the different
monitors.
> > > > >
> > > > > HTH
> > > > >
> > > > > Jomar
> > > >
> > > > When I use this command, matlab outputs:
> > > > 1 1 1024 768
> > > > -1679 -279 0 770
> > > >
> > > > It seems that 279+770 is close to the resolution of
my
> > > > second monitor height.
> > > >
> > > > Given this, do you know how I can make an image
appear on
> > > > that second monitor?
> > > >
> > > > I have both imshow and inputdlg commands that pop-up
> images
> > > > and boxes, respectively. Can I add something to
these
> > > > commands to make them automatically appear on the
second
> > screen?
> > > >
> > > > Thanks!
> > >
> > > The MonitorPositions property doesn't seem to return
useful
> > > information. I have investigated it on both Mac OS X
and
> > > Windows. The solution I came up with is this
function,
> > > screensize, which returns the proper coordinates of
multiple
> > > screens. I plan on submitting it to the FEX when I
get a
> > chance,
> > > but give it a try and let me know how it works out. I
> > need to
> > > add some documentation and work out a few minor
details.
> > >
> > > To use, just run with no arguments (I only have one
screen
> > right now):
> > >
> > > >> screensize
> > > ans =
> > > 1 0 1920 1200
> > >
> > > or pass in the screen number whose coordinates you
need:
> > >
> > > >> screensize(2)
> > > ans =
> > > 1 0 1920 1200
> > >
> > > If you don't have that many screens it'll still
return the
> > > coordinates of the highest-numbered one.
> > >
> > > And here's the function (watch for possible wrapped
lines):
> > >
> > >
> > > ------------------ screensize.m ----------------------
-----
> > > function ss_out = screensize(screen_number)
> > > %screensize: return screen coordinates of multiple
monitors.
> > >
> > > % Version: 1.0, 26 June 2008
> > > % Author: Douglas M. Schwarz
> > > % Email: dmschwarz=ieee*org,
> dmschwarz=urgrad*rochester*edu
> > > % Real_email = regexprep(Email,{'=','*'},{'@','.'})
> > >
> > >
> > > persistent ss
> > > if ~isempty(ss)
> > > num_screens = size(ss,1);
> > > if nargin == 0
> > > screen_number = 1:num_screens;
> > > end
> > > screen_index = min(screen_number,num_screens);
> > > ss_out = ss(screen_index,:);
> > > return
> > > end
> > >
> > > % Create an invisible figure (required for
> > get(0,'PointerLocation') to work
> > > % correctly on OS X).
> > > fig = figure('Visible','off');
> > >
> > > % Get initial location of mouse pointer.
> > > mouse_loc =
java.awt.MouseInfo.getPointerInfo.getLocation;
> > >
> > > % Create a robot to move mouse pointer.
> > > robot = java.awt.Robot;
> > >
> > > % Get Screen Devices array.
> > > sd =
> >
>
java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment.get
ScreenDevices;
> > >
> > > % Initialize screensize array.
> > > num_screens = length(sd);
> > > ss = zeros(num_screens,4);
> > >
> > > % Loop over all Screen Devices.
> > > for i = 1:num_screens
> > > % Get coordinate bounds of Screen Device.
> > > bounds = sd(i).getDefaultConfiguration.getBounds;
> > >
> > > % Move mouse pointer to lower left corner of this
> > screen and get MATLAB
> > > % coordinates of that point.
> > > robot.mouseMove(bounds.x, bounds.y +
bounds.height)
> > > pl_ll = get(0,'PointerLocation');
> > >
> > > % Move mouse pointer to upper right corner of this
> > screen and get
> > > % MATLAB coordinates of that point.
> > > robot.mouseMove(bounds.x + bounds.width, bounds.y)
> > > pl_ur = get(0,'PointerLocation');
> > >
> > > % Fill in screen size array.
> > > ss(i,:) = [pl_ll, pl_ur - pl_ll];
> > > end
> > >
> > > num_screens = size(ss,1);
> > > if nargin == 0
> > > screen_number = 1:num_screens;
> > > end
> > > screen_index = min(screen_number,num_screens);
> > > ss_out = ss(screen_index,:);
> > >
> > > % Return mouse pointer to initial location.
> > > robot.mouseMove(mouse_loc.x, mouse_loc.y)
> > >
> > > % Delete the figure.
> > > delete(fig)
> > >
> >
> ----------------------------------------------------------
-------
> > >
> > > --
> > > Doug Schwarz
> > > dmschwarz&ieee,org
> > > Make obvious changes to get real email address.
> >
> >
> > Thanks for these suggestions. When I run the function,
I get
> > the output:
> >
> > 1 1 1023 767
> > -1679 -1 1679 1049
> >
> > I am still not certain how to use these values to have
> > images and boxes automatically appear at those
positions.
> > When I try: fh=imshow('picture.bmp');set (fh, [-1679 -
1
> > 1679 1049]);
> >
> > I get an error saying that the parameter/value pair
> > arguments are invalid.
> >
> > Any other thoughts?
>
> Make sure you identify what parameter you want to set for
> fh. Your code above:
>
> set(fh, [-1679 -1 1679 1049]);
>
> doesn't identify a parameter that you're setting -- only
the
> object. Try this instead:
>
> set(fh, 'Position', [-1679 -1 1679 1049]);
>
This doesn't work because fh is a handle to an image object which does
not have a Position property.
>
> nor
>
> imshow(Picture.bmp');
> set(0,'DefaultFigurePosition',[-1119 314 560 420])
>
>
> make the picture appear on the second monitor. The picture
> still pops-up on the first monitor.
This doesn't work because you need to set the DefaultFigurePosition
*before* you create a new figure with imshow. Simply reverse the order
of these two commands. Better yet, put the set command in your startup
file like I said before (and run it or restart MATLAB) and all new
figures will be created on your second monitor.
--
Doug Schwarz
dmschwarz&ieee,org
Make obvious changes to get real email address.
According to the tips in this thread, I figured out my
screen sizes.
I do not want to setup the DefaultFigurePosition in a
startup file, as I use this only for one project. So I
follow the advice in
<SNIP>
> > imshow(Picture.bmp');
> > set(0,'DefaultFigurePosition',[-1119 314 560 420])
> [...]
> This doesn't work because you need to set the
DefaultFigurePosition
> *before* you create a new figure with imshow. Simply
reverse the order
> of these two commands. Better yet, put the set command
in your startup
> file like I said before (and run it or restart MATLAB)
and all new
> figures will be created on your second monitor.
>
<SNAP>
but still the figures show up on the first screen, moved as
far to the right as possible.
Using a set(gcf,'Position',newPosition) command on the
figure works to move the figure to the second screen, so I
could live with this solution, but 2 things are boggling me:
- Why does the defaultFigurePosition property not work
- I would like to getframe the figure from the second
screen in order to create a movie, but the command fails
with a
??? Error using ==> capturescreen
The rectangle passed to getframe must be at least partially
on screen.
Error in ==> getframe at 35
x=capturescreen(varargin{:});
Does anyone have a solution for this? (Despite the Psycho
Toolbox, which I'm not allowed to use/install on my system.
"Gwendolyn Fischer" <gwendolyn.fischer@nowhere.com> wrote in
message <g4a68q$g4q$1@fred.mathworks.com>...
> Hello,
>
> I've a similar problem.
>
> According to the tips in this thread, I figured out my
> screen sizes.
>
> I do not want to setup the DefaultFigurePosition in a
> startup file, as I use this only for one project. So I
> follow the advice in
>
> <SNIP>
> > > imshow(Picture.bmp');
> > > set(0,'DefaultFigurePosition',[-1119 314 560 420])
> > [...]
> > This doesn't work because you need to set the
> DefaultFigurePosition
> > *before* you create a new figure with imshow. Simply
> reverse the order
> > of these two commands. Better yet, put the set command
> in your startup
> > file like I said before (and run it or restart MATLAB)
> and all new
> > figures will be created on your second monitor.
> >
> <SNAP>
>
> but still the figures show up on the first screen, moved as
> far to the right as possible.
>
> Using a set(gcf,'Position',newPosition) command on the
> figure works to move the figure to the second screen, so I
> could live with this solution, but 2 things are boggling me:
>
> - Why does the defaultFigurePosition property not work
>
> - I would like to getframe the figure from the second
> screen in order to create a movie, but the command fails
> with a
>
> ??? Error using ==> capturescreen
> The rectangle passed to getframe must be at least partially
> on screen.
>
> Error in ==> getframe at 35
> x=capturescreen(varargin{:});
>
> Does anyone have a solution for this? (Despite the Psycho
> Toolbox, which I'm not allowed to use/install on my system.
>
> Thank you
>
> Gwen
Hi,
Yes, the set(gcf,'Position',newPosition) makes it so the
images appear on the second screen. However, they are quite
small-- is there a way to specify for them to be shown at
their full size (their size would be the exact same
dimensions of the second screen)?
Also, this set command doesn't seem to work for inputdlg
boxes. Is there another command for this?
Thanks!
Tags for this Thread
Add a New Tag:
Separated by commas
Ex.: root locus, bode
What are tags?
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.