Control a GUI (push button) from a script

7 Ansichten (letzte 30 Tage)
Steffen
Steffen am 6 Nov. 2015
Kommentiert: Steffen am 10 Nov. 2015
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

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Interactive Control and Callbacks finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by