Mamad
Mamad
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
i cheaked it in that website and it was valid
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
but it will correctly save and crop images
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
it returns a string with some none sense content
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
ok
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
but i cheaked it before and i didn't understand what it's doing
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
to be honest i have no idea because i copied this part of code
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
in G method?
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
it extracts an image from a website and turn it into byte array and then to Image
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
var HtmlW = driver.FindElement(By.XPath("/html/body")).GetAttribute("innerHTML").ToString();


string Image = GetHtmlW.G(HtmlW, $"id=\"{captchaId}\" src=\"data:image/jpeg;base64,", "\"");
var HtmlW = driver.FindElement(By.XPath("/html/body")).GetAttribute("innerHTML").ToString();


string Image = GetHtmlW.G(HtmlW, $"id=\"{captchaId}\" src=\"data:image/jpeg;base64,", "\"");
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
public class GetHtmlW
{

public static string G(string Html, string Value, string End)
{
int I = Html.IndexOf(Value);
string WS = "";

if (I > -1)
{
int W = I + Value.Length;
WS = Html.Substring(W, Html.IndexOf(End, W) - W);

}


return WS;
}
}
public class GetHtmlW
{

public static string G(string Html, string Value, string End)
{
int I = Html.IndexOf(Value);
string WS = "";

if (I > -1)
{
int W = I + Value.Length;
WS = Html.Substring(W, Html.IndexOf(End, W) - W);

}


return WS;
}
}
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
var bytes = Convert.FromBase64String(Image);
var bytes = Convert.FromBase64String(Image);
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
oh ok i see
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
should i pass the byte array to the memorystream?
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
nothing
using (MemoryStream ms = new MemoryStream())
{
imageIn.Save(ms, imageIn.RawFormat);
return ms.ToArray();
}
using (MemoryStream ms = new MemoryStream())
{
imageIn.Save(ms, imageIn.RawFormat);
return ms.ToArray();
}
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
what do you mean exactly?
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
i used bytes only in this part
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
Image screenshotPath1 = Image.FromFile("temp/cropped1.jpeg");
Image screenshotPath2 = Image.FromFile("temp/cropped2.jpeg");
Image screenshotPath3 = Image.FromFile("temp/cropped3.jpeg");
Image screenshotPath4 = Image.FromFile("temp/cropped4.jpeg");




byte[] bytes1 = null;
byte[] bytes2 = null;
byte[] bytes3 = null;
byte[] bytes4 = null;

bytes1 = ImageToByteArray(screenshotPath1);
bytes2 = ImageToByteArray(screenshotPath2);
bytes3 = ImageToByteArray(screenshotPath3);
bytes4 = ImageToByteArray(screenshotPath4);

screenshotPath1.Dispose();
screenshotPath2.Dispose();
screenshotPath3.Dispose();
screenshotPath4.Dispose();
Image screenshotPath1 = Image.FromFile("temp/cropped1.jpeg");
Image screenshotPath2 = Image.FromFile("temp/cropped2.jpeg");
Image screenshotPath3 = Image.FromFile("temp/cropped3.jpeg");
Image screenshotPath4 = Image.FromFile("temp/cropped4.jpeg");




byte[] bytes1 = null;
byte[] bytes2 = null;
byte[] bytes3 = null;
byte[] bytes4 = null;

bytes1 = ImageToByteArray(screenshotPath1);
bytes2 = ImageToByteArray(screenshotPath2);
bytes3 = ImageToByteArray(screenshotPath3);
bytes4 = ImageToByteArray(screenshotPath4);

screenshotPath1.Dispose();
screenshotPath2.Dispose();
screenshotPath3.Dispose();
screenshotPath4.Dispose();
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
Bitmap clone;

using (var ms = new MemoryStream(bytes))
{
clone = new Bitmap(ms);

clone = new Bitmap(clone, new Size(390, 90));

AdjustContrast(clone, 0.5f);
AdjustExposure(clone, -0.4f);

clone = clone.Clone(new Rectangle(0, 0, 230, 90), clone.PixelFormat);



CropAndSaveScreenshot(clone, SavePathAndName + 1 + ".jpeg", x1, y1, width1, height1);
CropAndSaveScreenshot(clone, SavePathAndName + 2 + ".jpeg", x2, y2, width2, height2);
CropAndSaveScreenshot(clone, SavePathAndName + 3 + ".jpeg", x3, y3, width3, height3);
CropAndSaveScreenshot(clone, SavePathAndName + 4 + ".jpeg", x4, y4, width4, height4);
clone.Save("temp/test.jpeg");
clone.Dispose();
}
Bitmap clone;

using (var ms = new MemoryStream(bytes))
{
clone = new Bitmap(ms);

clone = new Bitmap(clone, new Size(390, 90));

AdjustContrast(clone, 0.5f);
AdjustExposure(clone, -0.4f);

clone = clone.Clone(new Rectangle(0, 0, 230, 90), clone.PixelFormat);



CropAndSaveScreenshot(clone, SavePathAndName + 1 + ".jpeg", x1, y1, width1, height1);
CropAndSaveScreenshot(clone, SavePathAndName + 2 + ".jpeg", x2, y2, width2, height2);
CropAndSaveScreenshot(clone, SavePathAndName + 3 + ".jpeg", x3, y3, width3, height3);
CropAndSaveScreenshot(clone, SavePathAndName + 4 + ".jpeg", x4, y4, width4, height4);
clone.Save("temp/test.jpeg");
clone.Dispose();
}
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
This exception was originally thrown at this call stack: System.Drawing.Bitmap.Bitmap(System.IO.Stream) Kambiznet_bot.Bot.BotForm.TakeScreenshot(string, string) in BotForm.cs Kambiznet_bot.Bot.BotForm.CaptchaSolver(Microsoft.ML.ITransformer, Microsoft.ML.MLContext, string) in BotForm.cs Kambiznet_bot.Bot.BotForm.RegisterPerson(Kambiznet_bot.Models.Person) in BotForm.cs Kambiznet_bot.Bot.BotForm.StartBot(System.Collections.Generic.List<Kambiznet_bot.Models.Person>) in BotForm.cs Kambiznet_bot.Bot.BotForm.button1_Click.AnonymousMethod__20_0() in BotForm.cs System.Threading.Tasks.Task.Execute() in Task.cs Kambiznet_bot.Bot.BotForm.button1_Click(object, System.EventArgs) in BotForm.cs
63 replies
CC#
Created by Mamad on 10/19/2023 in #help
some problems with async await
in the last line of this method in the delegate class
63 replies