Screen scraping means a way to read / write on the representation of the current screen. You can, with this UDF, read the actual foreground of the screen or a background window. Hidden or minimized window are not supported. I tried to optimize the use of AutoIt as much as I could, but some actions require the performance of a DLL.
I have found multiple threads and others UDF discussing this subject but never found an optimized approach to this issue without gathering everything inside a large DLL.
The examples I am providing show how to use a background window (even if it is in the foreground when you run it directly with Scite) or use the current screen. Reading current screen is faster (about 20-30 ms faster) than reading a background window.
You need to first initialize the structure based on width and height. You can reuse the structure as long as you want if the dimensions do not change. You will need to make a new initialize if dimensions are changing. You do not need (this way) to have the actual size of a window. You can decide to reduce the dimensions to increase performance.
Supports x86 and x64.
The following functions are included in the UDF :
_GetScreen_Initialize($iWidth, $iHeight)
_GetScreen_GetScreen()
_GetScreen_GetWindow($hWnd, $iFlag = 0)
_GetScreen_GetPixel($iX, $iY)
_GetScreen_SetPixel($iX, $iY, $iValue)
_GetScreen_SearchArea($iLeft, $iTop, $iRight, $iBottom, $iColor, $iStart = 1)
_GetScreen_SearchAll($iColor, $iStart = 1)
_GetScreen_PixelReplaceArea($iColorFrom, $iColorTo, $iLeft, $iTop, $iRight, $iBottom)
_GetScreen_PixelReplaceAll($iColorFrom, $iColorTo)
_GetScreen_CheckSumArea($iLeft, $iTop, $iRight, $iBottom) _GetScreen_SaveFile($sFileName) _GetScreen_GetBitMap()
Version 2022-04-17
* Added new optional parameter $iFlag to _GetScreen_GetWindow
0 = full window for Win 7 and over
1 = client area for Win 7 and over
2 = full window for Win 10 and over (this can be used with applications (like Chrome) that do not support WM_PRINT or WM_PRINTCLIENT messages)
Version 2021-11-28
* Corrected a bug in SearchArea
Version 2021-08-30
* Fixed bugs related to areas
* Added support to repetitive searches in the same area
* Added a function to make a CheckSum of an area
* Added an additional example
Version 2021-08-24
* Removed unused structure
* Harmonized code
Example 1 : show various functions using the _GetScreen_GetWindow (background support)
Example 2 : show new functions using _GetScreen_GetScreen() (foreground only but faster)
All comments are very much welcome.
GetScreen.zip