Flood Visual Basic

Asked

Viewed 128 times

0

My goal is for the person to type a text. Let’s assume that in a textbox with multiline=true, and in that text, with each line break, that line is treated differently, like, every sentence in the textbox i can perform a different function if you like. Simply using some command referring to the text embeds everything written in textbox, and I wanted to line by line.

Another example: Let’s assume I want to make one flooder, then the person types what they want to be said in textbox and if I use in a Timer:

Clipboard.SetDataObject(TextBox1.Text, True)
    SendKeys.Send("^v{ENTER}")

With this code I was going to take what was written on textbox1 and once her mouse went through some dialog box, the message would be sent, but it would send all of the person’s sentences at once, and I want you to send them one by one separately, so I could even add a shipping interval between them.

The tool doesn’t need to be exactly one textbox, may be the one that works best and simplest.

1 answer

1


It’s very confusing your question, but I understand that you either separate lines and execute commands on these separate lines, well, come on.

Let’s create a method that executes actions in a single line, not to overload too much just a method:

Public Sub EvaluateLine(ByVal linha As String)
    Dim ItemsDaLinha As String() = linha.Split(" ")  ' Divide a linha por espaços
    Select Case ItemsDaLinha(0).ToLower()            ' Pega o primeiro item da linha
        Case "MandarMensagem"                        ' Quando o primeiro statement for um "EnviarMensagem"
            Dim ParaQuem$ = ItemsDaLinha(1)          ' Pega o primeiro argumento da linha
            If (String.IsNullOrWhitespace(ParaQuem)  ' Se o primeiro argumento for vazio ou nada...
                 Exit Sub                            ' Saia do método
            End If
            Dim Conteudo$ = linha.Substring(Len(ItemsDaLinha(0)) + Len(ItemsDaLinha(1)))
            Clipboard.SetString(Conteudo)            ' Obtém o conteúdo do código e joga para a área de transferência
     End Select
End Sub

In the above method, you emulate each line for an item of Case. Learn how to use Select... Case here. Here is a basic example for a line of code:

MandarMensagem Fulano Olá, mundo!

In this above message, the above method would interpret MandarMensagem as the first index of ItemsDaLinha(), Fulano as the second index, and finally, Olá, mundo! the Conteudo.


Now, to embody all lines of Textbox and that EvaluateLine execute all these lines, implement this method and call it when executing the command series:

Public Sub PerformText(ByVal code As String)
     ' Cria uma lista com todas as linhas de 'code'
     Dim linhas As String() = code.Split(Environment.NewLine)
     ' Faz um loop e executa todas as linhas
     For Each linhaAtual As String In linhas
           ' Chama o método que executa a linha
           EvaluateLine(linhaAtual)
     Next
End Sub

Ready. Now to run all these lines, call this method PerformText with the text of TextBox as an argument:

Public Sub Button1_Click(ByVal obj As Object, e As EventArgs) Handles Button1.Click
     Call PerformText(TextBox1.Text)
End Sub

To detect if the mouse is on top of a component, use the event Mousehover.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.