Code covered by the BSD License  

Highlights from
MOUSEINPUT_TIMEOUT

4.5

4.5 | 2 ratings Rate this file 34 Downloads (last 30 days) File Size: 2.4 KB File ID: #16539

MOUSEINPUT_TIMEOUT

by Gautam Vallabha

 

23 Sep 2007 (Updated 23 Jan 2012)

Captures continuous mouse movements with timeout

| Watch this File

File Information
Description

MOUSEINPUT_TIMEOUT returns continuous mouse locations with timeout

  OUT = MOUSEINPUT_TIMEOUT returns the sequence of mouse locations between a button press and a button release in the current axes. It does not timeout. OUT is an Nx2 matrix, where OUT(1,:) is the location at button press and OUT(END,:) is the location at button release.
 
  OUT = MOUSEINPUT_TIMEOUT(T) times out after a period of T seconds. T can be a fractional value (T=inf indicates no timeout). If the mouse-button has not been pressed during that time, OUT is []. If the timeout occurs during a mouse movement, OUT contains the mouse locations before the timeout.
  
  OUT = MOUSEINPUT_TIMEOUT(T,AH) records the mouse movement from the axes specified by axes handle AH.
   
Note: MOUSEINPUT_TIMEOUT differs from GINPUT in two ways.
(1) It does not return information about which mouse button was pressed,
(2) It ignores key presses.
 
-- Example:
% record movements from current axes
% (with timeout after 4.5 sec), and
% plot the final movement.
out = mouseinput_timeout(4.5, gca);
hold on;
plot(out(:,1),out(:,2),'r');
out(1,:) % location at button-press
out(end,:) % location at button-release

MATLAB release MATLAB 7.2 (R2006a)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (4)
12 Dec 2007 Cem Canciger

Dear Vallabha,

Code is excellent, thanks. But I'd like to ask something:

How can we acquire the mouse movements in real time by embedding your function to Simulink, or equivalently, is it possible to get real time mouse data?

23 Dec 2008 kakani young

this code works perfectly! it allows me to use a pen tablet to extract curves directly from image files.

22 Feb 2010 UTM ali

hi Vallabha
im working in online handwriting recognition.
that code is good. i can get (x,y)pts from pen online but the presure of the pen and time for every point i coudnt
can u adviceme
thanks

23 Feb 2010 Gautam Vallabha

@UTM ali:

It is not possible to get the pressure value of the pen (since the code uses the mouse interface).

You can get the time for every point by a small tweak to the code. At the start of the function get the current time:
    startTime = tic;
and change lines 89 and 99 to:
    selectedPts(end+1,:) = [pt(1,1:2) toc(startTime)];

Please login to add a comment or rating.
Updates
26 Sep 2007

Updated summary & keywords.

17 Nov 2009

Updated a minor typo that caused an error in R2009b. The function should now work from R2006a through R2009b.

23 Jan 2012

* Minor change to description

Tag Activity for this File
Tag Applied By Date/Time
gui tools Gautam Vallabha 22 Oct 2008 09:28:11
example Gautam Vallabha 22 Oct 2008 09:28:11
ginput Gautam Vallabha 22 Oct 2008 14:40:59
input Gautam Vallabha 22 Oct 2008 14:40:59
timeout Gautam Vallabha 22 Oct 2008 14:40:59
movement detection Gautam Vallabha 22 Oct 2008 14:40:59
movement direction Gautam Vallabha 22 Oct 2008 14:40:59
mouse motion Gautam Vallabha 22 Oct 2008 14:40:59
example UTM ali 15 Feb 2010 23:15:44

Contact us at files@mathworks.com