ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Demo project: Capture Control (CaptureFromScreen with iecsSpecifiedWindow)

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
PeterPanino Posted - Jul 25 2021 : 03:47:20
This demo project captures the control (window) under the mouse cursor of any window, for example:



attach/PeterPanino/202172534320_CaptureControlTest.zip
21.24 KB

This works very well - except with the CLIENT AREA OF WINDOWS NOTEPAD!

Why this does not work with the CLIENT AREA OF WINDOWS NOTEPAD? The rectangle coordinates of the CLIENT AREA OF WINDOWS NOTEPAD and its handle are reported correctly. Is this a bug in the CaptureFromScreen function?
7   L A T E S T    R E P L I E S    (Newest First)
xequte Posted - Jul 30 2021 : 15:19:40
Hi Peter

Next week.

Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Jul 30 2021 : 10:40:41
Hi Nigel

Thanks for the information.

When will the upcoming release be available?
xequte Posted - Jul 26 2021 : 16:56:16
Hi Peter

Please google "PrintWindow Fails" for more detail.

In the upcoming release we fall back to a legacy method.

Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Jul 26 2021 : 07:19:12
What is the technical reason for certain apps resisting a standard screen capture with CaptureFromScreen?
xequte Posted - Jul 26 2021 : 01:30:47
Hi Peter

iecsSpecifiedWindow2 is available for apps that resist a standard screen capture. You should check the boolean result of CaptureFromScreen, and if it is false fall back to CaptureFromScreen2:

procedure TForm1.Timer1Timer(Sender: TObject);
var
  pt: TPoint;
  h: HWND;
begin
  GetCursorPos( pt );
  if PtInRect( Self.BoundsRect, pt ) then
    exit; // Over own window

  h := Winapi.Windows.WindowFromPoint( pt ); // Handle of control under the mouse cursor
  if ImageEnView1.IO.CaptureFromScreen( iecsSpecifiedWindow, -1, h ) = False then
    ImageEnView1.IO.CaptureFromScreen( iecsSpecifiedWindow2, -1, h );
end;



Nigel
Xequte Software
www.imageen.com
PeterPanino Posted - Jul 25 2021 : 08:35:09
Other incompatible windows are Visual Studio Code, TechSmith Snagit Editor. Why are they incompatible with CaptureFromScreen?
PeterPanino Posted - Jul 25 2021 : 04:51:22
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?