窗口 – Haskell中的屏幕截图?
发布时间:2020-12-13 20:11:41 所属栏目:Windows 来源:网络整理
导读:是否可以在 Windows环境中使用Haskell捕获屏幕(或窗口)? (即每隔几分钟拍摄一次屏幕截图).如果是这样,那么怎么会这样做(再次,在Haskell,一个Windows环境)? 更多信息: 我是Haskell的初学者.一个朋友希望通过把他的会计师事务所的一些计划汇集在一起??,来削
是否可以在
Windows环境中使用Haskell捕获屏幕(或窗口)? (即每隔几分钟拍摄一次屏幕截图).如果是这样,那么怎么会这样做(再次,在Haskell,一个Windows环境)?
更多信息:
提到的方法是正确的.只是为了在上面给出的答案中添加一些代码
import Graphics.Win32.Window import Graphics.Win32.GDI.Bitmap import Graphics.Win32.GDI.HDC import Graphics.Win32.GDI.Graphics2D main = do desktop <- getDesktopWindow -- Grab the Hwnd of the desktop,GetDC 0,GetDC NULL etc all work too hdc <- getWindowDC (Just desktop) -- Get the dc handle of the desktop (x,y,r,b) <- getWindowRect desktop -- Find the size of the desktop so we can know which size the destination bitmap should be -- (left,top,right,bottom) newDC <- createCompatibleDC (Just hdc) -- Create a new DC to hold the copied image. It should be compatible with the source DC let width = r - x -- Calculate the width let height = b - y -- Calculate the Height newBmp <- createCompatibleBitmap hdc width height -- Create a new Bitmap which is compatible with the newly created DC selBmp <- selectBitmap newDC newBmp -- Select the Bitmap into the DC,drawing on the DC now draws on the bitmap as well bitBlt newDC 0 0 width height hdc 0 0 sRCCOPY -- use SRCCOPY to copy the desktop DC into the newDC createBMPFile "Foo.bmp" newBmp newDC -- Write out the new Bitmap file to Foo.bmp putStrLn "Bitmap image copied" -- Some debug message deleteBitmap selBmp -- Cleanup the selected bitmap deleteBitmap newBmp -- Cleanup the new bitmap deleteDC newDC -- Cleanup the DC we created. 这只是快速放在一起,但它保存了一个名为Foo.bmp的文件的屏幕截图.PS.对于谁写的Win32库,很好做:) (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows-vista – 如何在Windows Vista Home Edition上授予
- caliburn.micro – 使用Caliburn Micro 2和Windows Phone 8
- windows – 如何通过apt-cyg安装cygwin / X
- 如何在Windows Vista上编译为Linux / Unix编写的C源代码(给
- windows – 我可以在git中修改一个名称取决于操作系统的路径
- windows – 与WMF 4.0有任何已知的不兼容性吗?
- Windows-kms
- remote-desktop – 如何使用组策略禁用远程打印机
- windows-server-2008 – 备份虚拟机
- windows – 请推荐替代Microsoft HPC
推荐文章
站长推荐
热点阅读