2

From matlab it is possible to get a (java) reference to the matlab editor using these commands:

desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
jEditor = desktop.getGroupContainer('Editor').getTopLevelAncestor;

Thanks to Undocumented Matlab

Does anyone know how to get a reference to the Command Window?

It is impossible to obtain it the same way as the group titles do not include 'Command Window'

cl = desktop.getGroupTitles()

cl =


java.lang.String[]:
    'Editor'
    'Figures'
    'Web Browser'
    'Variables'
    'Comparison Tool'
    'Help'
    'Time Series Plots'
    'Scopes'
4

1 回答 1

4

Perhaps like this?:

desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
cmdwin = desktop.getClient('Command Window');

Maybe you need to add this too:

cmdwinview = cmdwin.getComponent(0).getViewport.getComponent(0);
h_cmdwin = handle(cmdwinview, 'CallbackProperties');

All of this comes from this forum thread: http://www.mathworks.com/matlabcentral/newsreader/view_thread/257842.

Remark: I am not a MATLAB/Java guru. Google, on the other hand, I can use :)

于 2013-09-03T12:11:23.697 回答