ScnLib_TakeScreenshot()

ScnLib_TakeScreenshotA/W()

Std EditionPro EditionMax EditionUltra Edition
C++ __declspec(dllimport) BOOL __stdcall ScnLib_TakeScreenshotA(LPSTR pszPath, long left, long top, long right, long bottom);
__declspec(dllimport) BOOL __stdcall ScnLib_TakeScreenshotW(LPWSTR pwszPath, long left, long top, long right, long bottom);
C# [DllImport("ScnLib.dll", CharSet = CharSet.Unicode)] public static extern bool ScnLib_TakeScreenshotW(StringBuilder Path, int left, int top, int right, int bottom);
Basic Public Declare Unicode Function ScnLib_TakeScreenshotW Lib "ScnLib.dll" (ByVal Path As StringBuilder, ByVal left As Int32, ByVal top As Int32, ByVal right As Int32, ByVal bottom As Int32) As Boolean
Delphi function ScnLib_TakeScreenshotA(Path: PAnsiChar; left: Integer; top: Integer; right: Integer; bottom: Integer): LongBool; stdcall; external 'ScnLib.dll';
function ScnLib_TakeScreenshotW(Path: PWideChar; left: Integer; top: Integer; right: Integer; bottom: Integer): LongBool; stdcall; external 'ScnLib.dll';
  • Description
    Take a screenshot of a designated screen region.

  • Parameters
    • Path [in/out]
      The input and output screenshot file path. Ensure that the allocated string buffer has a capacity greater than 260 characters. The supported screenshot image formats are PNG, BMP, JPG and TIFF. The file path may include any combination of following predefined variables:
      • <num> - Incorporate an automatically incrementing number into the file name to ensure its uniqueness.
      • <date> - Include a string representing the current date in the file name.
      • <time> - Include a string representing the current time in the file name.
      e.g. C:\Temp\Rec <date> <time>.png
    • left [in]
      The x-coordinate, in pixels, representing the upper-left corner of the screen capture region.
    • top [in]
      The y-coordinate, in pixels, representing the upper-left corner of the screen capture region.
    • right [in]
      The x-coordinate, in pixels, representing the lower-right corner of the screen capture region.
    • bottom [in]
      The y-coordinate, in pixels, representing the lower-right corner of the screen capture region.
    • The designated screen capture area excludes the right and bottom edges of the rectangle.
  • Return Value
    If the screenshot is taken and saved successfully, the return value is TRUE. Otherwise, the return value is FALSE.

  • Remarks
    Use this function to take a screenshot of a designated screen region. The file path can include a combination of predefined variables as described above. The Path string will provide the actual output file path. If you prefer not to use variables in the path, you can create a unique file path manually. Be aware that if the specified file path already exists, the file will be overwritten. The file extension determines the image format for the output, with supported formats including .PNG, .BMP, .JPG, and .TIFF.

    If the coordinates of an empty rectangle are specified, the current screen recording area will be captured. To capture a specific window, use the Win32 API function GetWindowRect() to obtain the window's rectangle, and then pass these coordinates to this function. For enabling users to select a screen capture region themselves, call ScnLib_SelectCaptureRegionA/W().

  • See Also
    ScnLib_SelectCaptureRegionA/W()

Try the SDK for FREE SDK APIs overview