FAQ - How to close onscreen windows on errors?


Q: If my script aborts with an error, I'm left with a dead Psychtoolbox window that prevents me from accessing the Matlab command window. How can I close the onscreen window in case of such an error?

A: There are different approaches. If Screen detects an error inside a Psychtoolbox MEX subcommand, it will automatically close all open windows and other resources. If your error is in regular Matlab code, e.g., your own code, or if you aborted your script via the CTRL + C keypress combo, you are left with such a dead window. The simplest way to close the window is to type blindly the command sca. sca is a little M-File which will close all windows (it's a quick and dirty way to access Screen('CloseAll')), show the mouse cursor again if it was hidden etc. If you don't get a reaction to that command, it may be that your hidden Matlab command window doesn't have the keyboard input focus. Try pressing Apple key + Tab key on OS/X, or ALT key + Tab key on Linux and Windows one or multiple times and retry typing sca + Enter key. This should eventually refocus the hidden Matlab command window, so the sca commands is really entered into the Matlab window and takes effect. If all this doesn't help, try pressing CTRL + C a couple of times before the Tab key -- it may be that your script is still running in the background, so it needs to be interrupted first.

Other options of error handling or debugging:

Good luck in debugging!
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki