Control a GUI (push button) from a script

24 views (last 30 days)
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

Accepted Answer

Walter Roberson
Walter Roberson on 7 Nov 2015
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 Comment
Steffen
Steffen on 10 Nov 2015
Thanks a lot, Walter.
I didn't know to call the pushbutton with an empty event. Makes sense now.

Sign in to comment.

More Answers (0)

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!