Run code in GUI automatically as soon as it starts

3 views (last 30 days)
Hi.
I have a GUI that contains an infinite loop for Data handling. My plan is to embed it in the Windows scheduled tasks so that it starts automatically every morning at 4 AM. I have created a button to break the loop when necessary.
Because the program will run on an unmonitored PC, I need the code to start automatically when the GUI starts. However, if I put it in the OpeningFcn, the code executes before the GUI becomes visible, so the GUI does not become visible at all (since it's an infinite loop) and so the button to cancel the loop never appears.
Does anyone have an idea for a workaround?

Accepted Answer

Image Analyst
Image Analyst on 1 Apr 2014
Put it in the OutputFcn - the GUI will be visible by the time it gets to the OutputFcn, which gets run as soon as the OpeningFcn has finished running.

More Answers (0)

Categories

Find more on Startup and Shutdown 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!