MATLAB Answers

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

10 ビュー (過去 30 日間)
Thomas Körner
Thomas Körner 2020 年 5 月 4 日
コメント済み: Thomas Körner 2020 年 5 月 6 日
Hi,
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
imshow(imgData)
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.

  0 件のコメント

Sign in to comment.

回答 (2 件)

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 月 5 日
I dont have Powerpoint
Jason Nicholson
Jason Nicholson 2020 年 5 月 6 日
Are you on Linux?
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.

Sign in to comment.


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.

Sign in to comment.

Categories


Translated by