0

hi im making my own Spammer which will spam text for me in c# now i found and problem with it that when ever i enter 1+ or +1 or (any number)+1 gives out ! or (given number)! and idk how to fix it btw here is the code where it sends the keys

//String & Ints
            int a, c;
            string b;

            //base program
            b = textBox1.Text;
            c = 1;
            a = Int32.Parse(textBox3.Text);
            Thread.Sleep(5000);

            //program
            for (; c <= a; c++)
            {
                SendKeys.SendWait(b);
                SendKeys.Send("{ENTER}");
            }
ZeyoYT
  • 19
  • 5
  • is your keyboard broken? No `,`,`.`,`?` or similar? – jps Jun 22 '20 at 12:03
  • 1
    "gives out !", what does this mean? Can you explain clearer what you're experiencing? – Lasse V. Karlsen Jun 22 '20 at 12:06
  • 3
    If you read the documentation for the [SendKeys.Send(String) Method](https://learn.microsoft.com/en-us/dotnet/api/system.windows.forms.sendkeys.send?view=netcore-3.1) you will see that `+` is a special character. See [Send special character with SendKeys](https://stackoverflow.com/questions/18299216/send-special-character-with-sendkeys/18299388). – Andrew Morton Jun 22 '20 at 12:17
  • @LasseV.Karlsen To SendKeys, "+1" represents shift key and 1, i.e. "!". – Andrew Morton Jun 22 '20 at 12:19
  • So you need to reformat your input to be the format required by SendKeys. – Lasse V. Karlsen Jun 22 '20 at 12:22
  • 1
    @LasseV.Karlsen i mean that the output of +1 gives our exclamatory mark but got it clear thanks to doome161 – ZeyoYT Jun 23 '20 at 07:29

1 Answers1

0

I would strongly advise you not to use Thread.Sleep. You may be able to specify a shortcut for this method.

If you have the possibility You might use the scripting language AutoHotKey. With this you could build a "spammer" much better and faster, but then you wouldn't have a graphical interface.

As already mentation "+ is a special character". The + represents here the pressing of the shift key. Thus Shift+1 = "!". You need to format the string from the textbox, as shown in the code below.

    int a, c;
    string b;

    //base program
    b = Regex.Replace(textBox1.Text, "[+^%~()]", "{$0}");
    c = 1;
    a = Int32.Parse(textBox3.Text);
    Thread.Sleep(5000);

    //program
    for (; c <= a; c++)
    {
        SendKeys.SendWait(b);
//changed to SendWait;
        SendKeys.SendWait("{ENTER}");
    }
doome161
  • 57
  • 5