From: Julie on
So, I have a C# application which calls Matlab:

MLApp app = new MLApp();
app.Execute(...);

This executes a .m file I have which produces a figure of a graph that pops up in a new window. Every 10 seconds, I reexecute this .m file in order to update the graph with new data. This causes Matlab to steal the focus on my computer, which makes it virtually impossible to type into other applications running on my machine, because what I'm typing instead gets entered into the Matlab command window.

What can I do to prevent Matlab from stealing focus on my computer?

Julie
From: ImageAnalyst on
Julie:
Here's the answer I got last November. Maybe it will work for you:

"It was a pleasure speaking with you this morning regarding 'Figures
stealing focus from OS'.

After some more investigation, I was able to find another workaround
for this issue. If you rewrite to the existing axes, rather than
create a new axes on every iteration of the loop, the figure should
stay in the background. The following code shows an example of this.

f = figure; % this will create and raise one figure
I = imread('pout.tif');
for i = 1:20
a = gca(f); % get the axes from the figure
cla(a); % clear the axes
imagesc(I);
pause(1)
I = I';
end

If you experience any trouble with this workaround, or if it does not
meet your needs, please let me know by replying to this email with the
THREAD ID below. This will allow your email to be routed directly to
my attention.

Kind regards,
Jen


Jen Dobson
Application Support Engineer
Technical Support Department
MathWorks
Phone: (508) 647-7000 option 2"

I wasn't creating a new axes every time, and I WAS using the same axes
every time. So, as I recall it, this didn't work. But you're welcome
to try this "official" answer.
From: Julie on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <2225fd7a-a93e-48ef-af27-6409d50ac9ed(a)d27g2000yqn.googlegroups.com>...
> Julie:
> Here's the answer I got last November. Maybe it will work for you:
>
> "It was a pleasure speaking with you this morning regarding 'Figures
> stealing focus from OS'.
>
> After some more investigation, I was able to find another workaround
> for this issue. If you rewrite to the existing axes, rather than
> create a new axes on every iteration of the loop, the figure should
> stay in the background. The following code shows an example of this.
>
> f = figure; % this will create and raise one figure
> I = imread('pout.tif');
> for i = 1:20
> a = gca(f); % get the axes from the figure
> cla(a); % clear the axes
> imagesc(I);
> pause(1)
> I = I';
> end
>
> If you experience any trouble with this workaround, or if it does not
> meet your needs, please let me know by replying to this email with the
> THREAD ID below. This will allow your email to be routed directly to
> my attention.
>
> Kind regards,
> Jen
>
>
> Jen Dobson
> Application Support Engineer
> Technical Support Department
> MathWorks
> Phone: (508) 647-7000 option 2"
>
> I wasn't creating a new axes every time, and I WAS using the same axes
> every time. So, as I recall it, this didn't work. But you're welcome
> to try this "official" answer.


I will take a look at this. Thanks for responding!
From: Duke Ng on
"Julie " <julie.vogelman(a)lmco.com> wrote in message <hkfags$2o7$1(a)fred.mathworks.com>...
> So, I have a C# application which calls Matlab:
>
> MLApp app = new MLApp();
> app.Execute(...);
>
> This executes a .m file I have which produces a figure of a graph that pops up in a new window. Every 10 seconds, I reexecute this .m file in order to update the graph with new data. This causes Matlab to steal the focus on my computer, which makes it virtually impossible to type into other applications running on my machine, because what I'm typing instead gets entered into the Matlab command window.
>
> What can I do to prevent Matlab from stealing focus on my computer?
>
> Julie

You can also try figure's *invisible* mode

fig = figure;
set(fig,'visible','off');
plot(c, fig);
close(fig);

Bests,

D.
From: Julie on
"Duke Ng" <duke.lists(a)gmx.com> wrote in message <hkfhuu$psm$1(a)fred.mathworks.com>...
> "Julie " <julie.vogelman(a)lmco.com> wrote in message <hkfags$2o7$1(a)fred.mathworks.com>...
> > So, I have a C# application which calls Matlab:
> >
> > MLApp app = new MLApp();
> > app.Execute(...);
> >
> > This executes a .m file I have which produces a figure of a graph that pops up in a new window. Every 10 seconds, I reexecute this .m file in order to update the graph with new data. This causes Matlab to steal the focus on my computer, which makes it virtually impossible to type into other applications running on my machine, because what I'm typing instead gets entered into the Matlab command window.
> >
> > What can I do to prevent Matlab from stealing focus on my computer?
> >
> > Julie
>
> You can also try figure's *invisible* mode
>
> fig = figure;
> set(fig,'visible','off');
> plot(c, fig);
> close(fig);
>
> Bests,
>
> D.

What does "invisible" mean? I do want my figure to be visible.