This is my code:
This is the code I am trying to implement:
Code:
Imports System.Runtime.InteropServices
Public Class Form1
Public Const WM_HOTKEY As Integer = &H312
<DllImport("User32.dll")> _
Public Shared Function RegisterHotKey(ByVal hwnd As IntPtr, _
ByVal id As Integer, ByVal fsModifiers As Integer, _
ByVal vk As Integer) As Integer
End Function
<DllImport("User32.dll")> _
Public Shared Function UnregisterHotKey(ByVal hwnd As IntPtr, _
ByVal id As Integer) As Integer
End Function
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
RegisterHotKey(Me.Handle, 100, Nothing, Keys.F10)
End Sub
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
If m.Msg = WM_HOTKEY Then
Select Case m.WParam.ToInt32
Case 100
If Not Timer1.Enabled Then
Timer1.Start()
Me.WindowState = 1
ElseIf Timer1.Enabled Then
Timer1.Stop()
Me.WindowState = vbNormal
End If
End Select
End If
MyBase.WndProc(m)
End Sub
Private Sub Form1_FormClosing(ByVal sender As System.Object, _
ByVal e As System.Windows.Forms.FormClosingEventArgs) _
Handles MyBase.FormClosing
UnregisterHotKey(Me.Handle, 100)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListBox1.Items.Add(TextBox1.Text)
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For Each Item In ListBox1.Items
SendKeys.Send(Item)
SendKeys.Send("{Enter}")
Threading.Thread.Sleep(TextBox2.Text)
Next
End Sub
End ClassThis is the code I am trying to implement:
Code:
Private WithEvents macroTimer As New Timer
Private WithEvents microTimer As New Timer
Private itemIndex As Integer = 0
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
macroTimer.Interval = 60 * 1000
macroTimer.Start()
microTimer.Interval = 1000
End Sub
Private Sub macroTimer_Tick(sender As Object, e As EventArgs) Handles macroTimer.Tick
microTimer.Start()
SendCurrentItem()
End Sub
Private Sub microTimer_Tick(sender As Object, e As EventArgs) Handles microTimer.Tick
SendCurrentItem()
If itemIndex = ListBox1.Items.Count Then
microTimer.Stop()
itemIndex = 0
End If
End Sub
Private Sub SendCurrentItem()
Dim itemText = ListBox1.GetItemText(ListBox1.Items(itemIndex))
SendKeys.Send(itemText)
SendKeys.Send("{Enter}")
itemIndex += 1
End SubThis thread is meant for jmcilhinney since I can't send this to him via PM since it contains too many characters.