try
    [w, rect] = Screen('Openwindow',0);
    cx = rect(3)/2;
    cy= rect(4)/2;
    myWidth = 2;
    mylength = 200;
    arrowsize = 40;
    displacement = cx/2;
    myx = cx-displacement;
    Instructions= 'Click any mouse button to create a dot in correspondence of the upper and lower limit of the line to your left.';
    Instructions2 = 'Click another time any mouse button when you are satisfied with your match';
    Screen('TextSize', w,12) ;
    ShowCursor ('CrossHair')
    SetMouse (myx,cy)
    count=0;
    clicks=0;
    Usery=0;
    Userdata=zeros(2,1);
    while count<2
        Screen('DrawText',w, Instructions, 10, 20);
        Screen('DrawText',w, Instructions2, 10, 40);
        Screen('DrawLine',w,0,cx+displacement, cy+mylength, ...
        cx+displacement, cy-mylength,myWidth);
        Screen('DrawLine',w,0,cx+displacement-arrowsize,cymylength+ ...
        arrowsize, cx+displacement,cy-mylength,myWidth);
        Screen('DrawLine',w,0,cx+displacement+arrowsize,cymylength+ ...
        arrowsize, cx+displacement,cy-mylength,myWidth);
        Screen('DrawLine',w,0,cx+displacement-arrowsize,cy+mylengtharrowsize, ...
        cx+displacement,cy+mylength,myWidth);
        Screen('DrawLine',w,0,cx+displacement+arrowsize,cy+mylengtharrowsize, ...
        cx+displacement,cy+mylength,myWidth);
        UserOval = [myx,Usery,myx+6,Usery+6];
        if clicks
            count=count+1;
            Screen('FillOval',w,0,UserOval);
            Userdata(count ,1)= Usery;
        end
        Screen('Flip',w );
        [clicks,Userx,Usery] = GetClicks;
    end
    Screen(w,'DrawText', sprintf('Your final length was %d, press any key to exit\n', Userdata(2,1)-Userdata(1,1)),10,60);
    Screen('Flip', w);
    while kbcheck end
    KbWait;
    Screen('Close',w)
catch
    Screen('Close',w)
    rethrow(lasterror)
end