# getmouse

**URL:** <https://psychtoolbox.discourse.group/t/getmouse/688>\
**Category:** Uncategorized\
**Created:** [October 3, 2003, 7:21pm UTC](https://psychtoolbox.discourse.group/t/getmouse/688 "2003-10-03T19:21:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksledgeccn](https://avatars.discourse-cdn.com/v4/letter/k/e99b99/32.png) [@ksledgeccn](https://psychtoolbox.discourse.group/u/ksledgeccn)\
**Post date:** [October 3, 2003, 7:21pm UTC](https://psychtoolbox.discourse.group/t/getmouse/688/1 "2003-10-03T19:21:45Z")

</div>

Hi--  
  
I'm having trouble using getMouse to record the location of a mouse click. For   
some reason, it is recording the location properly, but then when I go to, say,   
check for accuracy, everything is recorded as accurate.... Is something weird   
going on where I have to flushevents or something?  
  
Here is are two bits of my code:  
  
This records the location as x and y  
  
keepchecking = 1;  
while (keepchecking == 1)  
 [x,y,buttons] = GetMouse;  
 if any(buttons) % the mouse has been pressed,  
 keepchecking = 0; % end while-loop.  
 end   
end  
  
And this compares those values to what they are supposed to be. "missingx"   
and "missingy" are the correct values. I'm giving people 50 points in either   
direction as leeway.  
  
if (((missingx-50) \< x \< (missingx+50)) & ((missingy-50) \< y \< (missingy+50)))  
 trialmatrix(i,8) = 1;  
else  
 trialmatrix(i,8) = 0;  
end  
  
For some reason, no matter where I click, the value keeps getting set to 1,   
even if I'm way off. Any thoughts?
