Capture part of the desktop to a .BMP

Since version 3.2, HardCopy function allows to take a screenshot of the entire screen or the active window. Use the script below only if HardCopy function does not suit your needs.

This script captures a portion of the desktop to a .BMP file. If you want to capture the whole desktop, you can find the coordinates to specify in InArea parameters by using the script Get screen size.

 

'Capture part of the desktop

'The image is saved to a .BMP file

'You must specify the coordinates of the rectangle to capture

'You can use the Get_cursor_position example to help get these coordinates

 

UseWindow( "EXPLORER.EXE|SysListView32|Program Manager|1",1 )
res=CaptureBitmap( "C:\PROGRAM FILES\WINTASK\Scripts\desktop.bmp", InArea(0, 0, 100, 800) )

'display return code of CaptureBitmap function

msgbox(res)

'check the .BMP content

shell("pbrush "+chr$(34)+"C:\PROGRAM FILES\WINTASK\Scripts\desktop.bmp")