How to get global cursor type
5 views (last 30 days)
Show older comments
Hello,
I would like to obtain the cursor type (arrow, timeglass, busy...) while running an .m file which controls the position of the cursor in the (global) screen (i.e., not limited to the frame of MATLAB), that is cursor is hovering over an external application like a web browser for example while the m-file is still running. I am trying the following code segment:
java.awt.Cursor.GetType()
but it does not work.
In another attempt,
java.awt.MouseInfo.getPointerInfo().getDevice().getType()
does not help.
From https://www.mathworks.com/matlabcentral/answers/616-how-to-create-windows-forms-in-matlab, the following is extracted but it does not serve for my purpose either:
NET.addAssembly('System.Windows.Forms')
f = System.Windows.Forms.Form;
f.Cursor.Current.GetType %... this does not help, either.
As for java.Robot..., I could not come up with a code which does not produce error message either.
Could you please suggest a solution?
Thank you,
With kind regards,
EI
Edit 1: Setting the position of the cursor over the screen is not a problem. It can be done with following code:
screen=get(0);
%screen(3): width of the screen
%screen(4): height of the screen
[xy]=get(0,'PointerLocation');
% xy(1): x-position of the cursor
% xy(2): y-position of the cursor
x2=300; % 1<=x2<=screen(3);
y2=400; % 1<=y2<=screen(4);
set(0,'PointerLocation', [x2 y2]); %make the cursor move to point (x2,y2) on the screen
0 Comments
Answers (0)
See Also
Categories
Find more on Environment and Settings in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!