It seems that iecsSpecifiedWindow for some reason does not work with the CLIENT AREA OF WINDOWS NOTEPAD. So I created this workaround to automatically use iecsSpecifiedWindow2 if iecsSpecifiedWindow does not get the capture:
...
private
{ Private declarations }
...
FCurrentHash: AnsiString;
FOldHash: AnsiString;
...
GetCursorPos(FPoint);
if PTInRect(Self.BoundsRect, FPoint) then EXIT; // do not capture this window
FHandleOfWindowAtMousePos := Winapi.Windows.WindowFromPoint(FPoint); // Handle of Control under the mouse cursor
if FHandleOfWindowAtMousePos = FOldHandle then EXIT; // block the same handle as before
//CodeSite.Send('TForm1.Timer1Timer: FHandleOfWindowAtMousePos', FHandleOfWindowAtMousePos);
FOldHandle := FHandleOfWindowAtMousePos;
ImageEnView1.IO.CaptureFromScreen(iecsSpecifiedWindow, -1, FHandleOfWindowAtMousePos);
FCurrentHash := ImageEnView1.IEBitmap.GetHash();
if FCurrentHash = FOldHash then // if current bitmap is the same as before
begin
ImageEnView1.IO.CaptureFromScreen(iecsSpecifiedWindow2, -1, FHandleOfWindowAtMousePos); // alternative capture method
//CodeSite.Send('TForm1.Timer1Timer: alternative capture method');
end;
FOldHash := ImageEnView1.IEBitmap.GetHash();
ImageEnView1.Update;
Is this correct?