public static void myTyping(Instance instance, IZennoPosterProjectModel project, string text, int speedMin, int speedMax, int mistakePersent, bool enter)
{
{//============== typing with mistakes ==============
string str = text; // переменная с текстом
int latencyMin = speedMin; // минимальная задержка для ввода одного символа, мс
int latencyMax = speedMax; // максимальная задержка для ввода одного символа, мс
int percentE = mistakePersent; // процент вероятных ошибок (на конечный результат не влияет)
Random rnd = new Random();
string[] ss = {
"Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "A", "S", "D", "F", "G", "H", "J", "K", "L", "Z", "X", "C", "V", "B", "N", "M",
"q", "w", "e", "r", "t", "y", "u", "i", "o", "p", "a", "s", "d", "f", "g", "h", "j", "k", "l", "z", "x", "c", "v", "b", "n", "m",
"Ё", "Й", "Ц", "У", "К", "Е", "Н", "Г", "Ш", "Щ", "З", "Х", "Ъ", "Ф", "Ы", "В", "А", "П", "Р", "О", "Л", "Д", "Ж", "Э", "Я", "Ч", "С", "М", "И", "Т", "Ь", "Б", "Ю",
"ё", "й", "ц", "у", "к", "е", "н", "г", "ш", "щ", "з", "х", "ъ", "ф", "ы", "в", "а", "п", "р", "о", "л", "д", "ж", "э", "я", "ч", "с", "м", "и", "т", "ь", "б", "ю"
};
string[] ssE = {
"{W|A}", "{Q|E|A|S}", "{W|R|S|D}", "{E|T|D|F}", "{R|Y|F|G}", "{T|U|G|H}", "{Y|I|H|J}", "{U|O|J|K}", "{I|P|K|L}", "{O|L}", "{Q|S|Z}", "{W|E|A|D|Z|X}", "{E|R|S|F|X|C}", "{R|T|D|G|C|V}", "{T|Y|F|H|V|B}", "{Y|U|G|J|B|N}", "{U|I|H|K|N|M}", "{I|O|J|L|M}", "{O|P|K}", "{A|S|X}", "{S|D|Z|C}", "{D|F|X|V}", "{F|G|C|B}", "{G|H|V|N}", "{H|J|B|M}", "{J|K|N}",
"{w|a}", "{q|e|a|s}", "{w|r|s|d}", "{e|t|d|f}", "{r|y|f|g}", "{t|u|g|h}", "{y|i|h|j}", "{u|o|j|k}", "{i|p|k|l}", "{o|l}", "{q|s|z}", "{w|e|a|d|z|x}", "{e|r|s|f|x|c}", "{r|t|d|g|c|v}", "{t|y|f|h|v|b}", "{y|u|g|j|b|n}", "{u|i|h|k|n|m}", "{i|o|j|l|m}", "{o|p|k}", "{a|s|x}", "{s|d|z|c}", "{d|f|x|v}", "{f|g|c|b}", "{g|h|v|n}", "{h|j|b|m}", "{j|k|n}",
"!", "{Ц|Ф}", "{Й|У|Ф|Ы}", "{Ц|К|Ы|В}", "{У|Е|В|А}", "{К|Н|А|П}", "{Е|Г|П|Р}", "{Н|Ш|Р|О}", "{Г|Щ|О|Л}", "{Ш|З|Л|Д}", "{Щ|Х|Д|Ж}", "{З|Ъ|Ж|Э}", "{Х|Э}", "{Й|Ы|Я}", "{Ц|У|Ф|В|Я|Ч}", "{У|К|Ы|А|Ч|С}", "{К|Е|В|П|С|М}", "{Е|Н|А|Р|М|И}", "{Н|Г|П|О|И|Т}", "{Г|Ш|Р|Л|Т|Ь}", "{Ш|Щ|О|Д|Ь|Б}", "{Щ|З|Л|Ж|Б|Ю}", "{З|Х|Д|Э|Ю}", "{Х|Ъ|Ж}", "{Ф|Ы|Ч}", "{Ы|В|Я|С}", "{В|А|Ч|М}", "{А|П|С|И}", "{П|Р|М|Т}", "{Р|О|И|Ь}", "{О|Л|Т|Б}", "{Л|Д|Ь|Ю}", "{Д|Ж|Б}",
"1", "{ц|ф}", "{й|у|ф|ы}", "{ц|к|ы|в}", "{у|е|в|а}", "{к|н|а|п}", "{е|г|п|р}", "{н|ш|р|о}", "{г|щ|о|л}", "{ш|з|л|д}", "{щ|х|д|ж}", "{з|ъ|ж|э}", "{х|э}", "{й|ы|я}", "{ц|у|ф|в|я|ч}", "{у|к|ы|а|ч|с}", "{к|е|в|п|с|м}", "{е|н|а|р|м|и}", "{н|г|п|о|и|т}", "{г|ш|р|л|т|ь}", "{ш|щ|о|д|ь|б}", "{щ|з|л|ж|б|ю}", "{з|х|д|э|ю}", "{х|ъ|ж}", "{ф|ы|ч}", "{ы|в|я|с}", "{в|а|ч|м}", "{а|п|с|и}", "{п|р|м|т}", "{р|о|и|ь}", "{о|л|т|б}", "{л|д|ь|ю}", "{д|ж|б}"
};
string strE = str;
if (percentE > 0) {
for (int i = 0; i < strE.Length; i++) {
if (rnd.Next(100) <= percentE) {
string s = strE[i].ToString();
for (int j = 0; j < ss.Count(); j++) {
if (s == ss[j])
strE = strE.Remove(i, 1).Insert(i, TextProcessing.Spintax(ssE[j]));
}
}
}
}
instance.WaitFieldEmulationDelay();
for (int i = 0; i < str.Count(); i++) {
string s = str[i].ToString();
string sE = strE[i].ToString();
int latency = rnd.Next(latencyMin, latencyMax);
if (s == " " || s == "," || s == ".")
latency = latency * 2;
if (s == sE)
instance.SendText(s, latency);
else {
instance.SendText(sE, latency);
Thread.Sleep(latency * 3);
instance.SendText("{BACKSPACE}", latency);
Thread.Sleep(latency * 2);
instance.SendText(s, latency);
}
}
if(enter)
instance.SendText("{ENTER}",rnd.Next(15,300));
System.Threading.Thread.Sleep(rnd.Next(400,1000));
}//============== typing with mistakes end
}