register hotkeyfunction....
https://msdn.microsof*****m/en-us/lib...=vs.85%29.aspx
Example
Code:
Public Const WM_HOTKEY As Integer = &H312
Public Const NULL As Integer = &H0\
Public Declare Function RegisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer, ByVal fsModifiers As Integer, ByVal vk As Integer) As Integer
Public Declare Function UnregisterHotKey Lib "user32" (ByVal hwnd As IntPtr, ByVal id As Integer) As Integer
Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call RegisterHotKey(Me.Handle, 1, NULL, Keys.F1)
Call RegisterHotKey(Me.Handle, 2, NULL, Keys.F2)
FontComboBox1.Populate(True)
End Sub
Private Sub MainForm_FormClosing(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles MyBase.FormClosing
Call UnregisterHotKey(Me.Handle, 1)
Call UnregisterHotKey(Me.Handle, 2)
Application.ExitThread()
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_HOTKEY Then
Dim id As IntPtr = m.WParam
Select Case (id.ToString)
Case "1" : SpamText()
Case "2" : RichTextBox1.Text = ""
End Select
End If
MyBase.WndProc(m)
End Sub
Public Function HandleSendKeys(ByVal Richtextbox1 As String) As String
Richtextbox1 = Replace$(Richtextbox1, "{", Chr(1) & "{" & Chr(2))
Richtextbox1 = Replace$(Richtextbox1, "}", Chr(1) & "}" & Chr(2))
Richtextbox1 = Replace$(Richtextbox1, Chr(1), "{")
Richtextbox1 = Replace$(Richtextbox1, Chr(2), "}")
Richtextbox1 = Replace$(Richtextbox1, "+", "{+}")
Richtextbox1 = Replace$(Richtextbox1, "^", "{^}")
Richtextbox1 = Replace$(Richtextbox1, "%", "{%}")
Richtextbox1 = Replace$(Richtextbox1, "~", "{~}")
Richtextbox1 = Replace$(Richtextbox1, "(", "{(}")
Richtextbox1 = Replace$(Richtextbox1, ")", "{)}")
Richtextbox1 = Replace$(Richtextbox1, "[", "{[}")
Richtextbox1 = Replace$(Richtextbox1, "]", "{]}")
If CheckBox1.Checked = True Then
Richtextbox1 = Replace$(Richtextbox1, " ", "*")
End If
HandleSendKeys = Richtextbox1
End Function
Sub dELAYS(ByVal Interval As Integer)
System.Threading.Thread.Sleep(Interval)
End Sub
Public Sub SpamText()
RichTextBox1.ReadOnly = True : TextBox1.ReadOnly = True : TextBox2.ReadOnly = True
Lines = RichTextBox1.Lines
If Lines.Count > 0 Then
For Each strLine As String In Lines
If CheckBox2.Checked Then : SendKeys.Send(TextBox2.Text) : End If
SendKeys.Send(HandleSendKeys(strLine)) : SendKeys.Send("{ENTER}") : If (Not TextBox1.Text = Nothing) Then dELAYS(TextBox1.Text) Else
Next
RichTextBox1.ReadOnly = False : TextBox1.ReadOnly = False : TextBox2.ReadOnly = False
End If
End Sub
End Class