Control a GUI (push button) from a script

8 次查看(过去 30 天)
I have a GUI ('GUI1') which I want to control with a script. As I am not the owner nor administrator of 'GUI' I cannot change anything in the source code, however I do have access to it.
I would like to run 'GUI1' in the background, controlling it with my script. So far I have found the object handle via "findall" using the Tag. I tried to press the push button via the callback, however, it would not execute since it had not enough input arguments. This is the error that came:
feval(@(hObject,eventdata)ETD_Datamaster('File_browse_Callback',hObject,eventdata,guidata(hObject)))
Error using @(hObject,eventdata)GUI1('File_browse_Callback',hObject,eventdata,guidata(hObject))
Not enough input arguments.
What are the possibilities for controlling a GUI from a script? Has anyone done this before

采纳的回答

Walter Roberson
Walter Roberson 2015-11-7
You are passing a function handle to feval, and the function handle requires two arguments, but you are not providing any arguments.
file_browse_button_handle = findall('Tag', 'File_browse');
cb = get(file_browse_button_handle, 'Callback');
%now invoke the callback. hObject will be the button's own handle
cb(file_browse_button_handle, []); %uicontrol pushbutton have empty event
  1 个评论
Steffen
Steffen 2015-11-10
Thanks a lot, Walter.
I didn't know to call the pushbutton with an empty event. Makes sense now.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Interactive Control and Callbacks 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by