Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You should be able to do this with the Win32 API. Based on <a href="https://stackoverflow.com/questions/531684/what-is-the-best-way-to-take-screenshots-of-a-window-with-c-in-windows">What is the best way to take screenshots of a Window with C++ in Windows?</a>, you need to get the context of the window and then copy the image from it using <code>GetWindowDC</code> and <code>BitBlt</code> respectively.</p> <p>Looking around the Haskell Win32 API documentation, there is a <code>getWindowDC</code> function in <a href="http://hackage.haskell.org/packages/archive/Win32/2.2.2.0/doc/html/Graphics-Win32-Window.html" rel="nofollow noreferrer"><code>Graphics.Win32.Window</code></a>. This returns an <code>IO HDC</code>. There is a <code>bitblt</code> function in <a href="http://hackage.haskell.org/packages/archive/Win32/2.2.2.0/doc/html/Graphics-Win32-GDI-Graphics2D.html" rel="nofollow noreferrer"><code>Graphics.Win32.GDI.Graphics2D</code></a>. This function takes an <code>HDC</code> along with a bunch of <code>INT</code>s which presumably correspond to the arguments it takes in <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/dd183370(v=vs.85).aspx" rel="nofollow noreferrer">C++</a>.</p> <p>Unfortunately, I don't have a Windows machine handy, so I can't write the actual code. You'll have to figure out how to use the Win32 API functions yourself, which might be a bit of a bother. </p> <p>When you do, it would be great if you factored it into a library and put it up on Hackage--Windows does not usually get much love in Haskell land (as I myself show :P), so I'm sure other Windows programmers would be grateful for an easy way to take screenshots.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload