I have a loop in a loop to affect a lot of variables, after which I need to display the data in text form via SendKeys.Send and take a screenshot. But when the program starts, the loop produces screenshots, but in the text version it is displayed only at the last moment when all the screenshots have already been taken
private void button1_Click(object sender, EventArgs e)
{
int ID = Convert.ToInt32(textBox1.Text); //Тип одежды
int drawable = Convert.ToInt32(textBox2.Text); //Кол-во одежды
int Z = Convert.ToInt32(textBox3.Text); //Кол-во цветов
int all = 1;
Thread.Sleep(2000);
for(int i = 0; i < drawable + 1; i++)
{
int m1 = 0;
for (int m=m1; m< Z + 1;m++)
{
SendKeys.Send("t");
SendKeys.Send("/setclothes " + ID + " " + i + " " + m);
m1 = m;
int l = 32;
string filename = String.Format("D:\\Test\\" + ID + "_" + i + "_" + m + ".png", l);
Bitmap printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
Graphics graphics = Graphics.FromImage(printscreen as Image);
graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size);
printscreen.Save(filename, System.Drawing.Imaging.ImageFormat.Png);
}
}