Added some faux mouse polling since the movements were creating way too many events (this wasn't an issue in the past with low DPI mice)

Added a check to make sure the user cannot use the same Key twice for actions
Added a count down timer update for when a user is setting the start position so they know how long they need to wait
Added an offset to the final click in the action so the mouse re-clicks the app window into focus
Removed some unused code and Cleaned up some methods
This commit is contained in:
2022-09-29 00:06:54 +01:00
parent bb18cb14ce
commit a2ad5443d5
10 changed files with 177 additions and 38 deletions

View File

@ -7,9 +7,12 @@
Private _offsetX As Integer 'The mouse offset for X so that we can reset the actions x/y to 0 later
Private _offsetY As Integer 'The mouse offset for Y so that we can reset the actions x/y to 0 later
Private _pollingTicked As Boolean 'Polling tick for the mouse since mice today are like 5 million dpi and we dont need that much info
Private Sub FrmCapture_Load(sender As Object, e As EventArgs) Handles MyBase.Load
_graphics = Me.CreateGraphics()
_selectedKey = Nothing
_pollingTicked = True
_offsetX = 0
_offsetY = 0
End Sub
@ -32,25 +35,37 @@
End Sub
Private Sub FrmCapture_KeyDown(sender As Object, e As KeyEventArgs) Handles Me.KeyDown 'Method to listen for a keypress to set the actions key value
Dim selectedChar As Char = Chr(e.KeyValue)
If e.KeyCode = Keys.Escape Then 'If escape is hit then close the form
Me.Close()
ElseIf Char.IsLetter(Chr(e.KeyValue)) Or Char.IsNumber(Chr(e.KeyValue)) Then 'Check if its a letter or number input
_selectedKey = Chr(e.KeyValue)
LblKeySet.Text = Chr(e.KeyValue)
ElseIf Char.IsLetter(selectedChar) Or Char.IsNumber(selectedChar) Then 'Check if its a letter or number input
If Not FrmMain.mouseActionList.ContainsKey(selectedChar) Then ' Check if the key is already in the actions array
_selectedKey = Chr(e.KeyValue)
LblKeySet.Text = Chr(e.KeyValue)
Else
MsgBox("That key is already taken", MsgBoxStyle.Critical, "Taken!")
End If
End If
End Sub
Private Sub FrmCapture_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove 'Method to listen for mouse movements and to draw the action when the left button is clicked
If e.Button = Windows.Forms.MouseButtons.Left Then 'Wait for the left button to be held down
If _currentActionPointsList.Count > 0 Then 'If the action has already started recording then draw the connecting line
_graphics.DrawLine(_penColor, (_lastActionPoint.Item1 - Me.Location.X), (_lastActionPoint.Item2 - Me.Location.Y), (Cursor.Position.X - Me.Location.X), (Cursor.Position.Y - Me.Location.Y))
Else 'Otherwise set the initial offset values so that we can reset them to 0 and make them relative
_offsetX = Cursor.Position.X
_offsetY = Cursor.Position.Y
If _pollingTicked Then 'Check if the timer has ticked
If _currentActionPointsList.Count > 0 Then 'If the action has already started recording then draw the connecting line
_graphics.DrawLine(_penColor, (_lastActionPoint.Item1 - Me.Location.X), (_lastActionPoint.Item2 - Me.Location.Y), (Cursor.Position.X - Me.Location.X), (Cursor.Position.Y - Me.Location.Y))
Else 'Otherwise set the initial offset values so that we can reset them to 0 and make them relative
_offsetX = Cursor.Position.X
_offsetY = Cursor.Position.Y
End If
'Add the current X and Y to the list and set the "last" value
_currentActionPointsList.Add(Tuple.Create(Cursor.Position.X - _offsetX, Cursor.Position.Y - _offsetY))
_lastActionPoint = Tuple.Create(Cursor.Position.X, Cursor.Position.Y)
_pollingTicked = False
End If
'Add the current X and Y to the list and set the "last" value
_currentActionPointsList.Add(Tuple.Create(Cursor.Position.X - _offsetX, Cursor.Position.Y - _offsetY))
_lastActionPoint = Tuple.Create(Cursor.Position.X, Cursor.Position.Y)
End If
End Sub
Private Sub MovePoleTick_Tick(sender As Object, e As EventArgs) Handles MovePoleTick.Tick 'Method for when the timer has ticked to reset the polling and allow input
_pollingTicked = True
End Sub
End Class