try
    screens = Screen('Screens');
    whichscreen = max(screens);
    [myscreen,rect]=Screen('OpenWindow',whichscreen);
    DrawFormattedText(myscreen, 'PRESS THE SPACEBAR TO PROCEED', ...
        'center', 'center');
    Screen('Flip', myscreen);
    KbWait;
    Screen('Flip', myscreen);
    for i = 1:5
        [clicks, x, y, whichButton] = GetClicks;
        while ~clicks
            [clicks, x, y, whichButton] = GetClicks;
        end
        Screen('DrawText', myscreen,sprintf('This is the coordinate: X=%i, Y=%i ', x, y), x, y, 0);
        Screen('Flip', myscreen);
    end
    Screen('CloseAll');
catch
    Screen('CloseAll')
    rethrow(lasterror)
end