Skip to content

Commit

Permalink
fix: 修复长按快捷键时会触发多次推送的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
romebake committed Nov 6, 2020
1 parent 5c90f4c commit 8d3c85a
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
13 changes: 13 additions & 0 deletions AutoBark/AutoBark.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>zh-CN</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>
2 changes: 1 addition & 1 deletion AutoBark/MainForm.Designer.cs

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

10 changes: 9 additions & 1 deletion AutoBark/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -207,20 +207,28 @@ private void HttpSendBarkMsgThread(object obj)
}
}

private bool keyDownHandled = false;// 记录按键是否处理过,避免长按重复触发
private void hook_Start()
{
hook.KeyDownEvent += new KeyEventHandler(hook_KeyDown);
hook.KeyUpEvent += new KeyEventHandler(hook_KeyUp);
hook.Start();
}

private void hook_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyValue == (int)Keys.C && (int)Control.ModifierKeys == hotkeyDict[this.hotkeyComboBox.Text])
if (e.KeyValue == (int)Keys.C && (int)Control.ModifierKeys == hotkeyDict[this.hotkeyComboBox.Text] && keyDownHandled == false)
{
keyDownHandled = true;
this.SendBarkMsg();
}
}

private void hook_KeyUp(object sender, KeyEventArgs e)
{
keyDownHandled = false;
}

private void hotkeyCheckBox_CheckedChanged(object sender, EventArgs e)
{
bool hotkeyChecked = this.hotkeyCheckBox.Checked;
Expand Down
4 changes: 2 additions & 2 deletions AutoBark/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.1.0.0")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyVersion("1.2.0.0")]
[assembly: AssemblyFileVersion("1.2.0.0")]

0 comments on commit 8d3c85a

Please # to comment.