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

@ -1,22 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25123.0
# Visual Studio Version 17
VisualStudioVersion = 17.3.32901.215
MinimumVisualStudioVersion = 10.0.40219.1
Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "GoogleGameThing", "GoogleGameThing\GoogleGameThing.vbproj", "{E8891FA6-F0A6-4CD0-A7F5-70E384401321}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E8891FA6-F0A6-4CD0-A7F5-70E384401321}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E8891FA6-F0A6-4CD0-A7F5-70E384401321}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8891FA6-F0A6-4CD0-A7F5-70E384401321}.Debug|x64.ActiveCfg = Debug|x64
{E8891FA6-F0A6-4CD0-A7F5-70E384401321}.Debug|x64.Build.0 = Debug|x64
{E8891FA6-F0A6-4CD0-A7F5-70E384401321}.Debug|x86.ActiveCfg = Debug|x86
{E8891FA6-F0A6-4CD0-A7F5-70E384401321}.Debug|x86.Build.0 = Debug|x86
{E8891FA6-F0A6-4CD0-A7F5-70E384401321}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8891FA6-F0A6-4CD0-A7F5-70E384401321}.Release|Any CPU.Build.0 = Release|Any CPU
{E8891FA6-F0A6-4CD0-A7F5-70E384401321}.Release|x64.ActiveCfg = Release|x64
{E8891FA6-F0A6-4CD0-A7F5-70E384401321}.Release|x64.Build.0 = Release|x64
{E8891FA6-F0A6-4CD0-A7F5-70E384401321}.Release|x86.ActiveCfg = Release|x86
{E8891FA6-F0A6-4CD0-A7F5-70E384401321}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ED36CB52-55FE-4438-B35E-B90C0140E935}
EndGlobalSection
EndGlobal

View File

@ -1,9 +1,9 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class FrmCapture
Inherits System.Windows.Forms.Form
'Form overrides dispose to clean up the component list.
<System.Diagnostics.DebuggerNonUserCode()> _
<System.Diagnostics.DebuggerNonUserCode()>
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
@ -20,12 +20,14 @@ Partial Class FrmCapture
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
<System.Diagnostics.DebuggerStepThrough()> _
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.Label1 = New System.Windows.Forms.Label()
Me.Label2 = New System.Windows.Forms.Label()
Me.Label3 = New System.Windows.Forms.Label()
Me.LblKeySet = New System.Windows.Forms.Label()
Me.MovePoleTick = New System.Windows.Forms.Timer(Me.components)
Me.SuspendLayout()
'
'Label1
@ -63,6 +65,11 @@ Partial Class FrmCapture
Me.LblKeySet.Size = New System.Drawing.Size(0, 13)
Me.LblKeySet.TabIndex = 3
'
'MovePoleTick
'
Me.MovePoleTick.Enabled = True
Me.MovePoleTick.Interval = 1
'
'FrmCapture
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@ -84,4 +91,5 @@ Partial Class FrmCapture
Friend WithEvents Label2 As Label
Friend WithEvents Label3 As Label
Friend WithEvents LblKeySet As Label
Friend WithEvents MovePoleTick As Timer
End Class

View File

@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="MovePoleTick.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

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

View File

@ -24,6 +24,7 @@ Partial Class FrmMain
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Me.GroupBox1 = New System.Windows.Forms.GroupBox()
Me.TxtCap = New System.Windows.Forms.TextBox()
Me.CmdPos = New System.Windows.Forms.Button()
Me.lblMousePos = New System.Windows.Forms.Label()
Me.LblLastInput = New System.Windows.Forms.Label()
@ -34,7 +35,7 @@ Partial Class FrmMain
Me.CmdRecAct = New System.Windows.Forms.Button()
Me.PlayTime = New System.Windows.Forms.Timer(Me.components)
Me.PosSel = New System.Windows.Forms.Timer(Me.components)
Me.TxtCap = New System.Windows.Forms.TextBox()
Me.PosCountDown = New System.Windows.Forms.Timer(Me.components)
Me.GroupBox1.SuspendLayout()
Me.SuspendLayout()
'
@ -59,6 +60,14 @@ Partial Class FrmMain
Me.GroupBox1.TabStop = False
Me.GroupBox1.Text = "Tools"
'
'TxtCap
'
Me.TxtCap.Location = New System.Drawing.Point(219, 308)
Me.TxtCap.Name = "TxtCap"
Me.TxtCap.Size = New System.Drawing.Size(10, 20)
Me.TxtCap.TabIndex = 12
Me.TxtCap.Visible = False
'
'CmdPos
'
Me.CmdPos.Location = New System.Drawing.Point(3, 464)
@ -83,7 +92,7 @@ Partial Class FrmMain
Me.LblLastInput.Font = New System.Drawing.Font("Microsoft Sans Serif", 50.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.LblLastInput.Location = New System.Drawing.Point(80, 368)
Me.LblLastInput.Name = "LblLastInput"
Me.LblLastInput.Size = New System.Drawing.Size(73, 76)
Me.LblLastInput.Size = New System.Drawing.Size(72, 76)
Me.LblLastInput.TabIndex = 9
Me.LblLastInput.Text = "[]"
'
@ -141,14 +150,6 @@ Partial Class FrmMain
'
Me.PosSel.Interval = 5000
'
'TxtCap
'
Me.TxtCap.Location = New System.Drawing.Point(219, 308)
Me.TxtCap.Name = "TxtCap"
Me.TxtCap.Size = New System.Drawing.Size(10, 20)
Me.TxtCap.TabIndex = 12
Me.TxtCap.Visible = False
'
'FrmMain
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@ -176,4 +177,5 @@ Partial Class FrmMain
Friend WithEvents CmdPos As Button
Friend WithEvents PosSel As Timer
Friend WithEvents TxtCap As TextBox
Friend WithEvents PosCountDown As Timer
End Class

View File

@ -123,4 +123,7 @@
<metadata name="PosSel.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>117, 17</value>
</metadata>
<metadata name="PosCountDown.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>204, 17</value>
</metadata>
</root>

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

View File

@ -13,6 +13,21 @@
<MyType>WindowsForms</MyType>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@ -52,6 +67,57 @@
<PropertyGroup>
<ApplicationIcon>AppIcon.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<OutputPath>bin\x86\Debug\</OutputPath>
<DocumentationFile>GoogleGameThing.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<DefineTrace>true</DefineTrace>
<OutputPath>bin\x86\Release\</OutputPath>
<DocumentationFile>GoogleGameThing.xml</DocumentationFile>
<Optimize>true</Optimize>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<DefineDebug>true</DefineDebug>
<DefineTrace>true</DefineTrace>
<OutputPath>bin\x64\Debug\</OutputPath>
<DocumentationFile>GoogleGameThing.xml</DocumentationFile>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<DefineTrace>true</DefineTrace>
<OutputPath>bin\x64\Release\</OutputPath>
<DocumentationFile>GoogleGameThing.xml</DocumentationFile>
<Optimize>true</Optimize>
<NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release32|AnyCPU'">
<OutputPath>bin\Release32\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release32|x86'">
<OutputPath>bin\x86\Release32\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release32|x64'">
<OutputPath>bin\x64\Release32\</OutputPath>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
@ -138,6 +204,18 @@
<ItemGroup>
<Content Include="AppIcon.ico" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.6.1 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.

View File

@ -8,10 +8,10 @@ Imports System.Runtime.InteropServices
' Review the values of the assembly attributes
<Assembly: AssemblyTitle("WindowsApplication1")>
<Assembly: AssemblyDescription("")>
<Assembly: AssemblyCompany("")>
<Assembly: AssemblyProduct("WindowsApplication1")>
<Assembly: AssemblyTitle("Google Game thing")>
<Assembly: AssemblyDescription("Mouse Action mapper for some of the Google Browser games")>
<Assembly: AssemblyCompany("iDunnoDev")>
<Assembly: AssemblyProduct("Google Game thing")>
<Assembly: AssemblyCopyright("Copyright © 2016")>
<Assembly: AssemblyTrademark("")>
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' by using the '*' as shown below:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.0.0.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>
<Assembly: AssemblyVersion("1.0.1.0")>
<Assembly: AssemblyFileVersion("1.0.1.0")>

View File

@ -3,7 +3,7 @@
## Description
The Google Game thing is a small Visual Basic .net app that allows the user to draw shapes that can be used to emulate the same action at a given position with the left mouse button held.
This was created to be used with Googles 2016 Halloween doodle game, but could have other uses, you can even download and tweak it for your own purposes if needed!
This was created to be used with [Googles 2016 Halloween doodle game](https://www.google.com/doodles/halloween-2016), but could have other uses, you can even download and tweak it for your own purposes if needed!
## Installation
Just download the executable from the releases tab or compile it in visual studio and run.