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

@ -4,6 +4,10 @@
Public mouseActionStartPosition As Tuple(Of Integer, Integer) 'The start x and y location on the screen for the mouse action to move from
Private _mouseStartPositionSet As Boolean 'Bool to check if the user has set the start mouse position yet or not
'Ints to store a couple of tick values we can use to compare
Private _posSetStartTick As Integer
Private _posSetCurrentTick As Integer
Private Sub CmdExit_Click(sender As Object, e As EventArgs) Handles CmdExit.Click 'Quit the app
Me.Close()
@ -12,11 +16,10 @@
Private Sub CmdRecAct_Click(sender As Object, e As EventArgs) Handles CmdRecAct.Click
Dim capFrm As New FrmCapture
capFrm.Location = New Point(Me.Location.X - capFrm.Width, Me.Location.Y)
capFrm.ShowDialog()
End Sub
Private Sub CmdRemSel_Click(sender As Object, e As EventArgs) Handles CmdRemSel.Click 'Method for removing mouse actions from the action list
Private Sub CmdRemSel_Click(sender As Object, e As EventArgs) Handles CmdRemSel.Click 'Method for removing mouse actions from the action list1
Dim sel_text As String() = ChkActions.SelectedItem.ToString.Split(" | ")
ChkActions.Items.RemoveAt(ChkActions.SelectedIndex)
@ -39,7 +42,7 @@
mouse_event(&H4&, 0, 0, 0, 0) 'Release the left click
'Set the mouse location back to the app and click to try get focus, click and release the button incase it stuck for some reason, force focus and bring to the front
Cursor.Position = New Point(Me.Location.X, Me.Location.Y)
Cursor.Position = New Point(Me.Location.X + 10, Me.Location.Y + 10) 'Needs offset!
mouse_event(&H2&, 0, 0, 0, 0)
mouse_event(&H4&, 0, 0, 0, 0)
@ -56,7 +59,10 @@
End Sub
Private Sub CmdPos_Click(sender As Object, e As EventArgs) Handles CmdPos.Click
PosSel.Enabled = True 'Start the timer to listen for the start moust position method
_posSetStartTick = Environment.TickCount 'Get the enviroment time we can use to get the amount of milliseconds between 2 points in the app
_posSetCurrentTick = Environment.TickCount
PosSel.Start() 'Start the timer to listen for the start moust position method
PosCountDown.Start()
CmdPos.BackColor = Color.Green
End Sub
@ -65,7 +71,16 @@
lblMousePos.Text = "Mouse Pos: " & Cursor.Position.X & ":" & Cursor.Position.Y
CmdPos.BackColor = Color.Red
_mouseStartPositionSet = True
PosSel.Enabled = False
PosCountDown.Stop()
PosSel.Stop()
End Sub
Private Sub PosCountDown_Tick(sender As Object, e As EventArgs) Handles PosCountDown.Tick 'Method to update the pos label with a timer to show the user when the position has been taken
If PosSel.Enabled Then 'Check if the pos timer is currently running
_posSetCurrentTick = Environment.TickCount 'Get the current enviroment time to check how many millisecs have passed
Dim currentTimeElapsed As Integer = (PosSel.Interval - (_posSetCurrentTick - _posSetStartTick)) / 1000 'Get the time passed in seconds and count down from the inteval
lblMousePos.Text = "Pos Capture in: " & currentTimeElapsed.ToString()
End If
End Sub
End Class