Skip to content

Commit

Permalink
ダブルクリック時はキャンセルするよう修正
Browse files Browse the repository at this point in the history
  • Loading branch information
hirona98 committed Dec 17, 2021
1 parent 0ce1465 commit c034b8e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions imemd/Hook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class Hook
private IntPtr hHook;
private IntPtr lastClickWindow;
private DateTime lastWindowChange;
private DateTime lastClickTime;
private Win32API.HOOKPROC hHookProc;
private GCHandle allocHandle;

Expand All @@ -35,7 +36,6 @@ public bool SetMouseHook()
return false;
}

lastWindowChange = new DateTime();
lastWindowChange = DateTime.Now;
lastClickWindow = Win32API.GetForegroundWindow();

Expand Down Expand Up @@ -76,7 +76,7 @@ private bool IsExecAction()
// Chormeなら実行
if (IsChorme() == true)
{
Debug.WriteLine(", IsChorme() == true");
Debug.WriteLine("Exec, IsChorme() == true");
return true;
}

Expand Down Expand Up @@ -157,7 +157,15 @@ private async void InputZenkaku()
{
Debug.WriteLine("InputZenkaku()");

lastClickTime = DateTime.Now;
await Task.Delay(this.clickWaitMs); // ウインドウがアクティブになるのを待つ
if (lastClickTime.AddMilliseconds(this.clickWaitMs) > DateTime.Now)
{
// Delay中に二回目が来ていたらlaxtClickTimeが書き換わっている
Debug.WriteLine("Cancel(Double Click)");
lastClickTime = DateTime.Now;
return;
}

Win32API.INPUT input = new Win32API.INPUT
{
Expand Down
1 change: 1 addition & 0 deletions imemd/Win32API.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public enum MOUSE_MESSAGE
WM_LBUTTONUP = 0x0202,
WM_MOUSEMOVE = 0x0200,
WM_MOUSEWHEEL = 0x020A,
WM_LBUTTONDBLCLK = 0x0203,
WM_RBUTTONDOWN = 0x0204,
WM_RBUTTONUP = 0x0205
}
Expand Down
2 changes: 1 addition & 1 deletion imemd/imemd.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<ApplicationVersion>1.1.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
Expand Down

0 comments on commit c034b8e

Please sign in to comment.