User Tag List

9516Views
Results 1 to 5 of 5
  1. #1
    Member
    Join Date
    Feb 2015
    Posts
    26
    Coins
    0
    Thumbs Up
    Received: 3
    Given: 1

    C# download captcha image (geckoFX)

    need to mothode for download capctcha to disk

    i tested

    Code:
    Bitmap bmp = new Bitmap(WindowsImageCreator.GetBitmap(geckoWebBrowser1, 400, 850, 400, 150));
    bmp.Save(Application.StartupPath + "\\img1.gif", ImageFormat.Gif);
    this is not good for me beacuse captcha in my page , changes place every refresh :/

    if u know how to fix pls help me ...thx...

    Code:
    <div id="adcopy-puzzle-image" style="height: 150px; width: 300px; text-align: left;">
    <embed id="adcopy-puzzle-image-image" flashvars="url=https://freebitco.in/?op=home&clickTAG=https://api-secure.solvemedia.com/papi/action?c=2@Tw5szIz9haroDwT2alQdXZvD-dgNdDOh@UdmsANdYWdwENU8bgrSwNX9APTC4lJjoHezCUD.IVKVWNpkeY.bfdJ1Py2OznLAX6AroHrvqN3uYJtp6hjetFalkP83WGnhCgiqQo.2qR-J6Q5mFIvhutJ6yPcnS3W1VwLYZJf5l0w7HnxCdW30iGyVC-SNynyUqnMV1Hvlrqvnpb-fYVg3KjvmGk.2MyokUozKxuza2RrcwMjKdLy2t5Bw6yMjCK.Vf02cZp7qX6Lw6PkrjnBGAllOpbTaj6QbvxGkq3kPX.UPfQUAcc2Ft7YE4ZwbNAiQoJkhFXIK0uoA&listener=adcopy_media_listener" allowscriptaccess="always" wmode="opaque" style="width:100%;height:100%;padding:0;margin:0;" src="https://api-secure.solvemedia.com/acmedia/f/0/f0I51krdedeMNi/Q/Qkyq.r8drdedfsNs.swf" type="application/x-shockwave-flash">
    </div>



    0 Not allowed! Not allowed!

  2. #2
    Admin


    Join Date
    Dec 2014
    Posts
    200
    Coins
    6
    Thumbs Up
    Received: 44
    Given: 50
    Code:
                       foreach (GeckoHtmlElement imgelement in geckoWebBrowser1.Document.GetElementsByTagName("div"))
                        {
                            if (imgelement.GetAttribute("id")=="adcopy-puzzle-image")
                            {
                                GeckoImageElement ourimgage = (GeckoImageElement)imgelement;
                               Image ourimg = (System.Drawing.Bitmap)System.Drawing.Image.FromStream(new System.IO.MemoryStream(Gecko.Utils.SaveImageElement.ConvertGeckoImageElementToPng(geckoWebBrowser1, ourimgage, 0, 0, ourimgage.OffsetWidth, ourimgage.OffsetHeight)));
                            }
                        }
    This way you should get your image in 'ourimg' var. You can directly load it into picture box or save into disk.

    0 Not allowed! Not allowed!

  3. #3
    Elite Member onsali20's Avatar
    Join Date
    Nov 2014
    Location
    127.0.0.1
    Posts
    1,389
    Coins
    4
    Thumbs Up
    Received: 115
    Given: 12
    Has this been fixed?
    I will be more than happy to close this thread on your command.

    0 Not allowed! Not allowed!
    Still M̶o̶d̶e̶r̶a̶t̶i̶n̶g̶...
    .//ban @user
    "Stay Low, go fast. Kill first, Die last. One shot, One kill. No luck, all Skill."

  4. #4
    Member
    Join Date
    Feb 2015
    Posts
    26
    Coins
    0
    Thumbs Up
    Received: 3
    Given: 1
    I found this ... working good

    public void getsolvemedia(int a, int b)
    {

    Bitmap bmp = new Bitmap(CreateImage(wb));
    Rectangle cropRect = new Rectangle(a, b, 307, 157);
    bmp.Save("full.png");
    bmp = bmp.Clone(cropRect, bmp.PixelFormat);
    Image img = bmp;
    img = resizeImage(img, new Size(153, 79));
    img.Save("captcha.png");
    picture.Image = img;
    GeckoInputElement answer = new GeckoInputElement(wb.Document.GetElementsByName("a dcopy_response")[0].DomObject);
    answer.Value = captcha;
    if (captcha.Length >= 2)
    {
    GeckoButtonElement sub = new GeckoButtonElement(wb.Document.GetElementsByClassN ame("btn btn-warning")[0].DomObject);
    sub.Click();
    }
    }
    public static Image resizeImage(Image imgToResize, Size size)
    {
    return new Bitmap(imgToResize, size);
    }
    private Image CreateImage(GeckoWebBrowser browser)
    {
    var w = wb.Document.ActiveElement.ScrollWidth;
    var h = wb.Document.ActiveElement.ScrollHeight;

    var creator = new ImageCreator(browser);
    byte[] imageBytes = creator.CanvasGetPngImage((uint)w, (uint)h);
    using (var stream = new MemoryStream(imageBytes))
    {
    return Image.FromStream(stream);
    }
    }
    public Point GetOffset2(GeckoHtmlElement el)
    {
    Point pos = new Point(el.OffsetLeft, el.OffsetTop);
    GeckoHtmlElement tempEl = el.OffsetParent;
    while (tempEl != null)
    {
    pos.X += tempEl.OffsetLeft;
    pos.Y += tempEl.OffsetTop;
    tempEl = tempEl.OffsetParent;
    }
    return pos;
    }
    var point = GetOffset2(wb.Document.GetHtmlElementById("adcopy-outer"));
    var x = point.X;
    var y = point.Y;
    getsolvemedia(x, y);
    or easier methode

    using Gecko.Utils;

    Point GetScreenCordinates(GeckoHtmlElement obj)
    {
    Point p = new Point();

    try
    {
    p.X = obj.OffsetLeft;
    p.Y = obj.OffsetTop;

    GeckoHtmlElement _Parent = obj;
    while ((_Parent = _Parent.OffsetParent) != null)
    {
    p.X += _Parent.OffsetLeft;
    p.Y += _Parent.OffsetTop;
    }
    }
    catch { }

    return p;
    }

    private Bitmap GetElementAsImage(GeckoHtmlElement input)
    {
    Point cords = GetScreenCordinates(input);
    return ActiveBrowser.GetBitmap((uint)cords.X, (uint)cords.Y, (uint)input.ClientWidth, (uint)input.ClientHeight);
    }
    GetElementAsImage((GeckoHtmlElement)ActiveBrowser. Document.GetElementById("adcopy-outer"));
    Quote Originally Posted by onsali20 View Post
    Has this been fixed?
    I will be more than happy to close this thread on your command.
    Yest ...Solved ....Pls close.... thx for all

    0 Not allowed! Not allowed!
    Last edited by martin0409; 09-14-2015 at 12:53 PM.

  5. #5
    Admin


    Join Date
    Dec 2014
    Posts
    200
    Coins
    6
    Thumbs Up
    Received: 44
    Given: 50

    0 Not allowed! Not allowed!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •