The MASM Forum

Members Gallery => Showcase => Topic started by: jj2007 on May 20, 2022, 11:24:19 PM

Title: Save clipboard image to file
Post by: jj2007 on May 20, 2022, 11:24:19 PM
My trusty old PaintShop can, of course, paste an image from the clipboard and save it to a file. Oh well, it could do that, but for the last ten years (https://www.tek-tips.com/viewthread.cfm?qid=1447751) or so, all you see when pressing Ctrl V is this ugly little box:

(http://www.jj2007.eu/pics/PspUnableToGetDataFromTheClipboard.png)

Fortunately, if you only need a screenshot, you can use PaintShop's "capture" function.
Unfortunately, that function doesn't like, for reasons I don't understand, tooltips :sad:

Since I needed the tooltips for the WinAPI bubble help (http://masm32.com/board/index.php?topic=9875.msg110111#msg110111) post, I decided to help myself and roll my own from-clipboard-to-file proggie:

GuiParas equ "Right-click into the image", w1000, h562
include \masm32\MasmBasic\Res\MbGui.asm
  GuiControl MyCanvas, "canvas"
  ArraySet MyRect() As DWORD=1, 2, 3, 4         ; dummy values

Event CanvasPaint
  ArrayPlot MyRect()
  GuiImage clipboard, fit      ; right-click into the image brings up a popup menu
  ArrayPlot exit
GuiEnd


Source & exe attached. To test it, activate any window and press Alt PrintScreen, then launch the exe and right-click into the image.
Title: Re: Save clipboard image to file
Post by: jj2007 on October 09, 2022, 11:35:00 AM
New version attached, with some improvements. As with the previous one, make sure you have an image on the clipboard, then right-click into the window.

Note the easiest way to get a screenshot from a window is Alt PrtScr

Here is an example, a screenshot of this tool's source:

(http://www.jj2007.eu/pics/tmp.png)