Answer the question
In order to leave comments, you need to log in
Keystroke emulation (WinForms C#) with specific delay + random +-20ms delay?
Greetings to all, in fact, the question is in the header. I hope you can help (send a sample code).
In my program, the user presses his key in one form, after which, the code-number (int) of this button is written to a separate class, I need to implement in another class the function of constantly pressing this key (by code) with a certain delay and to it + - 20 ms through some random function to add or subtract.
Tell me how to implement it? I will be very grateful :)
public void NewForm_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.PageDown)
{
if (Storage.IsEnabled == true)
{
Storage.IsEnabled = false;
StatusOnOff.BackColor = Color.Red;
}
}
if (e.KeyCode == Keys.PageUp)
{
if (Storage.IsEnabled == false)
{
Storage.IsEnabled = true;
StatusOnOff.BackColor = Color.Green;
}
}
}
private void ChooseKeyForm_KeyDown(object sender, KeyEventArgs e)
{
Storage.KeyData = e.KeyValue;
this.Dispose();
}
internal class Storage
{
public static int KeyData { get; set; }
public static bool IsEnabled { get; set; }
}
class SpamKeyFunc
{
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question