How do I control GUI's from matlab script/function?

8 次查看(过去 30 天)
Hello,
I am trying to automate the use of a GUI within a script/function I am writing. I can't change the GUI because it is not mine. I need to open the GUI, open a file within the GUI, enter in values into user input boxes, run nested functions, output the results, close the GUI, and then repeat with new inputs.
Does anyone know how to do this, or have an example?
Thanks

回答(2 个)

Image Analyst
Image Analyst 2013-1-29
You'd need to know tags and handles for all the controls on the GUI you want to interact with. Apparently you don't have access to the source code (or else you'd just make your modifications in that), so that means you don't know the tags and handles for that GUI and therefore you won't know how to change anything on it. (Well there are ways that I know of, but they require findobj() and a lot of detective work or guessing.)

Jan
Jan 2013-1-29
编辑:Jan 2013-1-29
This seems to be an excellent example for a bad GUI implementation. It sounds like the graphical user interface has been totally mixed with the computational part. In consequence modifying, maintaining or using the program is far more complicated than with a clean code with strictly separated data, computations and GUI.
As soon as you try to control this GUI remotely, any changes to the GUI will invalidate your program also. Therefore I'm strongly convinced, that you should not und no circumstances set a complicated method on top of an already to complicated GUI/computational code desaster. The costs for maintaining such a software junk will exceed the costs for reprogramming the GUI and the computations in a strictly separated manner.
Ok, this is my opinion so far. I've seen too many software projects failing for such ideas of using a worse design as workaround for a bad design. Now to your question:
You can get the names of the callback functions and depending on how the GUI has been created, you can trigger the calls from the outside also. You can get the handles of the objects by GUIDATA and the replied handles struct, if it has been created properly. But this matters only, if you are talking about a Matlab GUI. If you mean an external program, use the java.awt.robot and cruel tools like KeyInject and TextInject. And if the result is horrible, please do not blame me ;-)

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

产品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by