Ok, here's my problem. When I check check box cbPause
(cbPause = true
) then my count start 1
not 0
. The counter is named tickCount and if I put tickCount
inside of if (cbPause.Checked == true)
. If I put it ad the end of my Interval method it also starts with 1 and not 0. Where should I place incrementing variable, in my situation, so it starts with 0? I must have tickCount++;
somewhere, but I don't know where.
PS. tickCount is used to see which line I must type. It starts from 0 so I type line 0 from ListBox.
This is a main timer counts time between each message typed:
private void Interval(object sender, EventArgs e)
{
if (cbPause.Checked == true)
{
randomLine = random.Next(lbMessage.Items.Count);
tmrSpace.Enabled = true;
}
else
{
if (cbRandomLine.Checked == true)
{
SendKeys.Send(lbMessage.Items[random.Next(lbMessage.Items.Count)].ToString() + "{enter}");
}
else
{
if (tickCount < lbMessage.Items.Count)
{
SendKeys.Send(lbMessage.Items[tickCount].ToString() + "{enter}");
if (tickCount == lbMessage.Items.Count) tickCount = 0;
tickCount++;
}
}
}
SetInterval();
}
This method is a second timer which allows me to type like a typewriter which types string with small time spaces between each character.
private void Space(object sender, EventArgs e)
{
if (cbRandomLine.Checked == true)
{
SendKeys.Send(lbMessage.Items[randomLine].ToString().Substring(currentChar++, 1));
if (currentChar == lbMessage.Items[randomLine].ToString().Length)
{
SendKeys.Send("{enter}");
tmrSpace.Enabled = false;
currentChar = 0;
}
}
else
{
if (tickCount < lbMessage.Items.Count)
{
SendKeys.Send(lbMessage.Items[tickCount].ToString().Substring(currentChar++, 1));
if (currentChar == lbMessage.Items[tickCount].ToString().Length)
{
SendKeys.Send("{enter}");
tmrSpace.Enabled = false;
currentChar = 0;
}
}
}
tmrSpace.Interval = random.Next(50, 100);
}
Any tips are highly appreciated. Thank you in advance.