How can I capture a screenshot WITH the cursor displayed in Matlab?

조회 수: 2(최근 30일)
I want to make a screenshot of my current desktop and want the cursor be displayed in the picture. All methods I tried so far didnt display the cursor (cursor is just invisible). Any method to do it?
EDIT: For those who want to know how I solved my problem: I didn't find any direct method to do it inside Matlab. Instead I use OBS to capture a region of my screen. In my case its a computer game that is in window mode and takes only a third of my actual screen. In the preview window of OBS I can then see a live footage of that game with a visible cursor. Then I do a screenshot of my screen in Matlab using the java robot class:
% Take screen capture
robot = java.awt.Robot();
pos = [0 0 3440 1440]; % [left top width height]
rect = java.awt.Rectangle(pos(1),pos(2),pos(3),pos(4));
cap = robot.createScreenCapture(rect);
% Convert to an RGB image
rgb = typecast(cap.getRGB(0,0,cap.getWidth,cap.getHeight,[],0,cap.getWidth),'uint8');
imgData = zeros(cap.getHeight,cap.getWidth,3,'uint8');
imgData(:,:,1) = reshape(rgb(3:4:end),cap.getWidth,[])';
imgData(:,:,2) = reshape(rgb(2:4:end),cap.getWidth,[])';
imgData(:,:,3) = reshape(rgb(1:4:end),cap.getWidth,[])';
% Show or save to file
The next step would be to extract the area where the preview window of OBS is located (or: directly define the image capture position in pos = [...]).
The result is a picture of the game that contains a visible cursor and is loaded in the matlab workspace.
Of course if you want the cursor to be as big on the picture as in the game you will need to scale the preview window of OBS to the same size as the window of the game.


Jason Nicholson
Jason Nicholson 2020년 5월 5일
Record the screen using Screen Recording in PowerPoint? A screen capture won't work but a screen recording will.
  댓글 수: 3
Thomas Körner
Thomas Körner 2020년 5월 6일
No Windows 10. I solved the Problem on my own (see edit). Thanks for help though.

댓글을 달려면 로그인하십시오.

Hannes Ernst
Hannes Ernst 2020년 5월 5일
You could use a desktop Magnifier (e. g. the standard one from Microsoft called with the shortcut "Windows Key" + "+"). Just set it to 100 % (original scale) and make a screenshot from the desktop magnifier view. In case of pointing out code you could just mark the relevant passage.
  댓글 수: 1
Thomas Körner
Thomas Körner 2020년 5월 5일
I oponed the tool and did a screenshot with matlab, but I still cant see the Cursor on the image.

댓글을 달려면 로그인하십시오.


Find more on Video games 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!

Translated by