Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
How to make SnapShot
-
- Posts: 44
- Joined: Sun Jul 07, 2019 1:46 pm
How to make SnapShot
Hello.
Is there way to get snapshot when application form with Chromium is not visible?
I've tried built in TakeSnapshot, but it works only when Chromium is on screen.
I need it to get Captha images, because built in downloadimage downloads a new captcha (but i need to use current, opened in Webbrowser captcha image).
Thank you!
Is there way to get snapshot when application form with Chromium is not visible?
I've tried built in TakeSnapshot, but it works only when Chromium is on screen.
I need it to get Captha images, because built in downloadimage downloads a new captcha (but i need to use current, opened in Webbrowser captcha image).
Thank you!
- salvadordf
- Posts: 4575
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to make SnapShot
Try the "Take screenshot" menu option in the MiniBrowser demo.
https://github.com/salvadordf/CEF4Delph ... .pas#L1111
https://github.com/salvadordf/CEF4Delph ... .pas#L1111
Re: How to make SnapShot
I think, in this case, it is better to use the event GetResourceResponseFilter, to save a captcha while loading on the fly.
Learn the demo ResponseFilterBrowser, It shows how to save resources in TMemoryStream, and there you can do whatever you want with them.
Learn the demo ResponseFilterBrowser, It shows how to save resources in TMemoryStream, and there you can do whatever you want with them.
Re: How to make SnapShot
Sorry, I can't figure out this example, if it's not difficult, show the code how to save logo.png which is in the example without replacing it?Student wrote: Tue Aug 25, 2020 10:16 am I think, in this case, it is better to use the event GetResourceResponseFilter, to save a captcha while loading on the fly.
Learn the demo ResponseFilterBrowser, It shows how to save resources in TMemoryStream, and there you can do whatever you want with them.
- salvadordf
- Posts: 4575
- Joined: Thu Feb 02, 2017 12:24 pm
- Location: Spain
- Contact:
Re: How to make SnapShot
All the code is in the ResponseFilterBrowser demo but it's not simple.w1ld32 wrote: Sun Oct 11, 2020 10:50 amSorry, I can't figure out this example, if it's not difficult, show the code how to save logo.png which is in the example without replacing it?Student wrote: Tue Aug 25, 2020 10:16 am I think, in this case, it is better to use the event GetResourceResponseFilter, to save a captcha while loading on the fly.
Learn the demo ResponseFilterBrowser, It shows how to save resources in TMemoryStream, and there you can do whatever you want with them.
If you know the URL of the image consider using TChromium.DownloadImage instead.
Re: How to make SnapShot
The picture changes every time ((salvadordf wrote: Sun Oct 11, 2020 12:13 pmAll the code is in the ResponseFilterBrowser demo but it's not simple.w1ld32 wrote: Sun Oct 11, 2020 10:50 amSorry, I can't figure out this example, if it's not difficult, show the code how to save logo.png which is in the example without replacing it?Student wrote: Tue Aug 25, 2020 10:16 am I think, in this case, it is better to use the event GetResourceResponseFilter, to save a captcha while loading on the fly.
Learn the demo ResponseFilterBrowser, It shows how to save resources in TMemoryStream, and there you can do whatever you want with them.
If you know the URL of the image consider using TChromium.DownloadImage instead.
https://instagram777.ru/captcha2.php
Re: How to make SnapShot
I got out of the situation like this: after loading the page, I find the coordinates of the captcha, take a screenshot and cut out the captcha using these coordinates.
Re: How to make SnapShot
You need to make changes to the ReplaceLogo procedure, and then in FStream your resource will be located. I can't guarantee that my code is written correctly,w1ld32 wrote: Tue Oct 13, 2020 9:20 am I got out of the situation like this: after loading the page, I find the coordinates of the captcha, take a screenshot and cut out the captcha using these coordinates.
some types of resources may be of unknown size, and I have additional checks in the code.
Code: Select all
FStreamCS.Acquire;
if (data_in = nil) then
begin
data_in_read := 0;
data_out_written := 0;
if FRscCompleted and ((FRscSize = -1) or (FRscSize = FStream.size)) then
begin
aResult := RESPONSE_FILTER_DONE;
PostMessage(handle, STREAM_COPY_COMPLETE, 0, 0);
end else aResult := RESPONSE_FILTER_NEED_MORE_DATA;
end
else
begin
aResult := RESPONSE_FILTER_DONE;
if (data_out <> nil) then
begin
data_out_written := min(data_in_size, data_out_size);
if (data_out_written > 0) then
Move(data_in^, data_out^, data_out_written);
end;
if (data_in_size > 0) then
data_in_read := FStream.Write(data_in^, data_in_size);
if not(FRscCompleted) and (FRscSize <> -1) and (FRscSize = FStream.size)
then
FRscCompleted := PostMessage(handle, STREAM_COPY_COMPLETE, 0, 0)
else if data_out_written = 65536 then
aResult := RESPONSE_FILTER_NEED_MORE_DATA
else
FRscCompleted := PostMessage(handle, STREAM_COPY_COMPLETE, 0, 0);
end;
FStreamCS.Release;
Re: How to make SnapShot
Thank You. I Try it.Student wrote: Tue Oct 13, 2020 9:42 amYou need to make changes to the ReplaceLogo procedure, and then in FStream your resource will be located. I can't guarantee that my code is written correctly,w1ld32 wrote: Tue Oct 13, 2020 9:20 am I got out of the situation like this: after loading the page, I find the coordinates of the captcha, take a screenshot and cut out the captcha using these coordinates.
some types of resources may be of unknown size, and I have additional checks in the code.
Code: Select all
FStreamCS.Acquire; if (data_in = nil) then begin data_in_read := 0; data_out_written := 0; if FRscCompleted and ((FRscSize = -1) or (FRscSize = FStream.size)) then begin aResult := RESPONSE_FILTER_DONE; PostMessage(handle, STREAM_COPY_COMPLETE, 0, 0); end else aResult := RESPONSE_FILTER_NEED_MORE_DATA; end else begin aResult := RESPONSE_FILTER_DONE; if (data_out <> nil) then begin data_out_written := min(data_in_size, data_out_size); if (data_out_written > 0) then Move(data_in^, data_out^, data_out_written); end; if (data_in_size > 0) then data_in_read := FStream.Write(data_in^, data_in_size); if not(FRscCompleted) and (FRscSize <> -1) and (FRscSize = FStream.size) then FRscCompleted := PostMessage(handle, STREAM_COPY_COMPLETE, 0, 0) else if data_out_written = 65536 then aResult := RESPONSE_FILTER_NEED_MORE_DATA else FRscCompleted := PostMessage(handle, STREAM_COPY_COMPLETE, 0, 0); end; FStreamCS.Release;