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

Post Reply
ForestListener
Posts: 44
Joined: Sun Jul 07, 2019 1:46 pm

How to make SnapShot

Post by ForestListener »

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!
User avatar
salvadordf
Posts: 4042
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to make SnapShot

Post by salvadordf »

Try the "Take screenshot" menu option in the MiniBrowser demo.
https://github.com/salvadordf/CEF4Delph ... .pas#L1111
Student
Posts: 72
Joined: Tue Aug 07, 2018 9:20 am

Re: How to make SnapShot

Post by Student »

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.
ForestListener
Posts: 44
Joined: Sun Jul 07, 2019 1:46 pm

Re: How to make SnapShot

Post by ForestListener »

Thank you!
w1ld32
Posts: 19
Joined: Wed Feb 12, 2020 10:28 am

Re: How to make SnapShot

Post by w1ld32 »

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.
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?
User avatar
salvadordf
Posts: 4042
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: How to make SnapShot

Post by salvadordf »

w1ld32 wrote: Sun Oct 11, 2020 10:50 am
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.
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?
All the code is in the ResponseFilterBrowser demo but it's not simple.
If you know the URL of the image consider using TChromium.DownloadImage instead.
w1ld32
Posts: 19
Joined: Wed Feb 12, 2020 10:28 am

Re: How to make SnapShot

Post by w1ld32 »

salvadordf wrote: Sun Oct 11, 2020 12:13 pm
w1ld32 wrote: Sun Oct 11, 2020 10:50 am
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.
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?
All the code is in the ResponseFilterBrowser demo but it's not simple.
If you know the URL of the image consider using TChromium.DownloadImage instead.
The picture changes every time ((
https://instagram777.ru/captcha2.php
w1ld32
Posts: 19
Joined: Wed Feb 12, 2020 10:28 am

Re: How to make SnapShot

Post by w1ld32 »

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.
Student
Posts: 72
Joined: Tue Aug 07, 2018 9:20 am

Re: How to make SnapShot

Post by Student »

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.
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,
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;
w1ld32
Posts: 19
Joined: Wed Feb 12, 2020 10:28 am

Re: How to make SnapShot

Post by w1ld32 »

Student wrote: Tue Oct 13, 2020 9:42 am
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.
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,
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;
Thank You. I Try it.
Post Reply