Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions KeyboardUnchatter/App.config
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="KeyboardChatterFix.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="KeyboardUnchatter.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<userSettings>
<KeyboardChatterFix.Properties.Settings>
<KeyboardUnchatter.Properties.Settings>
<setting name="chatterThreshold" serializeAs="String">
<value>20</value>
</setting>
Expand All @@ -19,6 +19,11 @@
<setting name="activateOnLaunch" serializeAs="String">
<value>True</value>
</setting>
</KeyboardChatterFix.Properties.Settings>
<setting name="disabledKeys" serializeAs="Xml">
<value>
<ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" />
</value>
</setting>
</KeyboardUnchatter.Properties.Settings>
</userSettings>
</configuration>
</configuration>
23 changes: 11 additions & 12 deletions KeyboardUnchatter/DataGridController.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace KeyboardUnchatter
Expand Down Expand Up @@ -84,25 +80,28 @@ public void AddKeyBlock(Keys key)
private void UpdateGridCell(KeyData keyData)
{
bool cellUpdated = false;
var keyPressed = keyData.Key.ToString();
var keyDisabled = Properties.Settings.Default.disabledKeys.Contains(keyPressed);
int press = keyData.KeyPressedCount;
int block = keyData.KeyBlockedCount;
var percentage = Math.Floor((float)block / (float)press * 100).ToString() + "%";

for (int a = 0; a < _dataGrid.Rows.Count; ++a)
{
var row = _dataGrid.Rows[a];
var keyColumnCell = row.Cells[1];

if (row.Cells[0].Value != null && row.Cells[0].Value.ToString() == keyData.Key.ToString())
if (keyColumnCell.Value != null && keyColumnCell.Value.ToString() == keyPressed)
{
int press = keyData.KeyPressedCount;
int block = keyData.KeyBlockedCount;

_dataGrid.Rows[a].SetValues(new string[] { keyData.Key.ToString(), press.ToString(), block.ToString(), (Math.Floor((float)block/(float)press*100)).ToString() +"%" });
_dataGrid.Rows[a].SetValues(new object[] { keyDisabled, keyPressed, press.ToString(), block.ToString(), percentage});
cellUpdated = true;
break;
}
}

if (!cellUpdated)
{
int press = keyData.KeyPressedCount;
int block = keyData.KeyBlockedCount;
_dataGrid.Rows.Add(new string[] { keyData.Key.ToString(), press.ToString(), block.ToString(), (Math.Floor((float)block / (float)press)*100).ToString() + "%" });
_dataGrid.Rows.Add(new object[] { keyDisabled, keyPressed, press.ToString(), block.ToString(), percentage });
}
}
}
Expand Down
16 changes: 10 additions & 6 deletions KeyboardUnchatter/KeyboardMonitor.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Diagnostics;


namespace KeyboardUnchatter
Expand Down Expand Up @@ -60,6 +58,7 @@ private bool HandleKey(InputHook.KeyPress keyPress)
}

var key = _keyStatusList.GetKey(keyPress.KeyCode);
var unchatterDisabled = Properties.Settings.Default.disabledKeys.Contains(keyPress.Key.ToString());

if (keyPress.Status == InputHook.KeyStatus.Down)
{
Expand All @@ -69,17 +68,21 @@ private bool HandleKey(InputHook.KeyPress keyPress)
if (lastPressStatus == KeyStatusList.PressStatus.Up && key.IsBlocked)
{
Debug.Log("Key"+ key.KeyCode+" is blocked. Discarding");
return false;
if (!unchatterDisabled)
return false;
}

double timeSpan = key.GetLastPressTimeSpan();

if(timeSpan < _chatterTimeMs)
{
Debug.Log("Key" + key.KeyCode + " timeSpawn is below limit. Blocking");
key.Block();
RegisterChatterPress(keyPress.Key);
return false;
if (!unchatterDisabled)
{
key.Block();
return false;
}
}
}

Expand All @@ -94,7 +97,8 @@ private bool HandleKey(InputHook.KeyPress keyPress)
if (keyWasBlocked && key.GetBlockTimeSpan() < _chatterTimeMs)
{
Debug.Log("Key" + key.KeyCode + " was blocked");
return false;
if (!unchatterDisabled)
return false;
}
else
{
Expand Down
4 changes: 3 additions & 1 deletion KeyboardUnchatter/KeyboardUnchatter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<OutputType>WinExe</OutputType>
<RootNamespace>KeyboardUnchatter</RootNamespace>
<AssemblyName>KeyboardUnchatter</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
Expand All @@ -26,6 +26,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -84,6 +85,7 @@
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="MainWindow.resx">
<DependentUpon>MainWindow.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
Expand Down
15 changes: 12 additions & 3 deletions KeyboardUnchatter/MainWindow.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 15 additions & 7 deletions KeyboardUnchatter/MainWindow.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Diagnostics;

namespace KeyboardUnchatter
{
Expand Down Expand Up @@ -149,6 +142,21 @@ private void OnActivateOnLaunchCheckBox(object sender, EventArgs e)
Properties.Settings.Default.Save();
}

private void OnDisabledCheckBox(object sender, DataGridViewCellEventArgs e)
{
if (e.ColumnIndex == this.Disabled.Index)
{
var cell = this._mainDataGrid[e.ColumnIndex, e.RowIndex];
var isChecked = !(bool)cell.Value;
cell.Value = isChecked; // Toggle checkbox manually, datagrid is in programmatic edit mode
string pressedKey = this._mainDataGrid.Rows[e.RowIndex].Cells[1].Value.ToString();
if (isChecked)
Properties.Settings.Default.disabledKeys.Add(pressedKey);
else
Properties.Settings.Default.disabledKeys.Remove(pressedKey);
Properties.Settings.Default.Save();
}
}

private void DataSortCompare(object sender, DataGridViewSortCompareEventArgs e)
{
Expand Down
12 changes: 0 additions & 12 deletions KeyboardUnchatter/MainWindow.resx
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,6 @@
<metadata name="FailureRate.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="Key.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="PressCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="ChatterCount.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="FailureRate.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="_notifyIcon.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
Expand Down
2 changes: 1 addition & 1 deletion KeyboardUnchatter/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 14 additions & 1 deletion KeyboardUnchatter/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion KeyboardUnchatter/Properties/Settings.settings
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="KeyboardChatterFix.Properties" GeneratedClassName="Settings">
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="KeyboardUnchatter.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="chatterThreshold" Type="System.Decimal" Scope="User">
Expand All @@ -11,5 +11,9 @@
<Setting Name="activateOnLaunch" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="disabledKeys" Type="System.Collections.Specialized.StringCollection" Scope="User">
<Value Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;ArrayOfString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" /&gt;</Value>
</Setting>
</Settings>
</SettingsFile>