How to graph current Pointer Location

3 次查看(过去 30 天)
For a current project I am trying to graph a current representation of the pointer from my computer. I know how to get the current pointer location using:
>>get(0,'PointerLocation') ans = x-coordinate y-coordinate
I know that I need to create a loop in order to do this. What would I need to write as a script in order to graph the current pointer location? I've seen an example and the graph's point should move about the graph's parameters just as the pointer would move about the computer monitor's parameters.
Any advice would be beneficial! Matthew
  1 个评论
matt dash
matt dash 2014-11-21
Not clear if you want the pointer moving over a matlab figure and it leaves a trail behind it, like you're drawing, or if the pointer is moving over non-matlab windows and its trail is being plotted in a separate window. This will change the implementation.

请先登录,再进行评论。

采纳的回答

Adam
Adam 2014-11-21
编辑:Adam 2014-11-21
Something like the following would work, although this is an infinite loop. I haven't put any thought into how you would terminate it - I had to use Ctrl C
figure; hold on
while(1)
xy = get(0,'PointerLocation');
plot( xy(1), xy(2), 'Marker', '+' )
drawnow
pause( 0.1)
end
Obviously that is just a guide, you can set your own marker type, colour, type of plot etc.
To have the plot so that it literally follows the mouse would be trickier - you would have to preset the axis limits to match your screen size, allowing for the frame around the axes, etc.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by