Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi test

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!

Problem 1917. click away

Write a function that clicks on a GUI button.


Some times one wishes to use Matlab to automate some time consuming repetitive process that requires filling fields or clicking buttons on the screen. Matlab offers a simple way to control the cursor position (e.g. set(0,'pointerlocation',...), but it is not so clear how one would perform mouse or keyboard clicks.

This problem creates a simple message box:

 msgbox('Click the OK button','')

which displays the above message and an 'OK' button.

Your function just needs to actually click on the OK button (or use equivalent keyboard shortcuts) to pass this problem. Simple, right?


Problem Group

Solution Statistics

11 correct solutions 51 incorrect solutions
Last solution submitted on May 20, 2015

Solution Comments