设置切换键

时间:2018-01-31 17:23:54

标签: vb.net

我目前正在使用人工随机化进行自动转换。 我遇到的问题是,我不知道如何制作一个可以绑定密钥然后使其运行的东西。到目前为止,这是我的代码,如果您对如何改进代码有任何想法,请分享,我主要需要改进我的随机化。

我如何制作一个让用户可以设置切换键的东西?

Public Class Form1

Public Const MOUSEEVENTF_LEFTDOWN = &H2
Public Const MOUSEEVENTF_LEFTUP = &H4
Private Const MOUSEEVENTF_RIGHTDOWN = &H8
Private Const MOUSEEVENTF_RIGHTUP = &H10


Declare Function mouse_autoClicker Lib "user32.dll" Alias "mouse_event" (ByVal dwFlags As Int32, ByVal dX As Int32, ByVal dY As Int32, ByVal cButtons As Int32, ByVal dwExtraInfo As Int32) As Boolean

Private Sub StartClick()
    System.Windows.Forms.Cursor.Position = New System.Drawing.Point(System.Windows.Forms.Cursor.Position)
    Call mouse_autoClicker(MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0)
    Call mouse_autoClicker(MOUSEEVENTF_LEFTUP, 0, 0, 0, 0)
End Sub

Private Sub TrackStart_Scroll(sender As Object, e As EventArgs) Handles TrackStart.Scroll
    If TrackStart.Value > TrackEnd.Value Then
        TrackStart.Value = TrackEnd.Value
    End If
    valstart.Text = trackstart.Value
End Sub
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Me.Text = "ClickDevastator v.0.7"
End Sub
Private Sub TrackEnd_Scroll(sender As Object, e As EventArgs) Handles trackend.Scroll
    If trackend.Value < trackstart.Value Then
        trackend.Value = trackstart.Value
    End If
    ValEnd.Text = trackend.Value
End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    Dim rnd As New Random
    Dim ClickString As Integer = rnd.Next(Val(valstart.Text), Val(ValEnd.Text))
    txtRnd.Text = ClickString.ToString()
    Timer2.Enabled = True
    For i As Integer = 0 To Val(txtRnd.Text) - 1
        StartClick()
    Next

End Sub

Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnstart.Click

    If btnstart.Text = "Start" Then
        Timer1.Enabled = True
        btnstart.Text = "Stop"
        btnstart.ForeColor = Color.Red
    ElseIf btnstart.Text = "Stop" Then
        Timer1.Enabled = False
        btnstart.Text = "Start"
        btnstart.ForeColor = Color.LawnGreen
    End If

End Sub

Private Sub btnClick_Click(sender As Object, e As EventArgs) Handles btnclick.Click
    txtClick.Text = Val(txtClick.Text) + 1
End Sub

Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
    valstart.Text = Date.Now.ToString("hh : mm : ss")
End Sub

Private Sub Timer1_Disposed(sender As Object, e As EventArgs) Handles Timer1.Disposed
    Timer2.Enabled = False
End Sub

Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown
    If e.KeyCode = Keys.Escape Then
        If btnstart.Text = "Stop" Then
            btnstart.PerformClick()
        End If
    End If
End Sub

Private Sub Label1_Click(sender As Object, e As EventArgs)

End Sub

Private Sub btn1_Click(sender As Object, e As EventArgs) Handles btnstart.Click

End Sub

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles txtRnd.TextChanged

End Sub

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btnclick.Click

End Sub

Private Sub Label2_Click(sender As Object, e As EventArgs) Handles ValEnd.Click

End Sub

Private Sub label1_Click_1(sender As Object, e As EventArgs) Handles valstart.Click

End Sub

Private Sub BindingNavigatorDeleteItem_Click(sender As Object, e As EventArgs)

End Sub

Private Sub Label1_Click_2(sender As Object, e As EventArgs)

End Sub

Private Sub trackstart_Scroll_1(sender As Object, e As EventArgs) Handles trackstart.Scroll

End Sub

Private Sub Label1_Click_3(sender As Object, e As EventArgs)

End Sub

Private Sub Label1_Click_4(sender As Object, e As EventArgs) Handles Label1.Click

End Sub

Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click

End Sub
End Class

1 个答案:

答案 0 :(得分:0)

Toggle in code适用于像这样的布尔值......

new