Skip to content

Commit 2aa14db

Browse files
committed
Fix issue when release Alt key before H key
1 parent 45e1cc4 commit 2aa14db

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

speech-to-windows-input/Program.cs

+11-3
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ private static bool kbdHook_KeyDownEvent(llc.KeyboardHook sender, uint vkCode, b
234234
{
235235
if (vkCode == (uint)Keys.H && !keyHDown)
236236
{
237-
keyHDown = true;
238237
if (llc.Keyboard.IsKeyDown((int)Keys.Menu))
239238
{
239+
keyHDown = true;
240240
ToggleSTT();
241241
return true;
242242
}
@@ -261,15 +261,15 @@ private static bool kbdHook_KeyDownEvent(llc.KeyboardHook sender, uint vkCode, b
261261
}
262262
else if (vkCode >= (uint)Keys.D0 && vkCode <= (uint)Keys.D9 && !keyConfigDown)
263263
{
264-
keyConfigDown = true;
265264
if (config.UseSwitchConfigKey && llc.Keyboard.IsKeyDown((int)Keys.Menu))
266265
{
266+
keyConfigDown = true;
267267
configId = (vkCode - (uint)Keys.D0);
268268
shouldReloadConfig = true;
269269
return true;
270270
}
271271
}
272-
else if (vkCode == (uint)Keys.Escape)
272+
else if (vkCode == (uint)Keys.Escape && !injected)
273273
{
274274
if (recognizing)
275275
{
@@ -282,7 +282,11 @@ private static bool kbdHook_KeyDownEvent(llc.KeyboardHook sender, uint vkCode, b
282282
private static bool kbdHook_KeyUpEvent(llc.KeyboardHook sender, uint vkCode, bool injected)
283283
{
284284
if (vkCode == (uint)Keys.H && keyHDown)
285+
{
285286
keyHDown = false;
287+
if (!llc.Keyboard.IsKeyDown((int)Keys.Menu))
288+
llc.Keyboard.SendKey((int)Keys.Escape);
289+
}
286290
else if (vkCode == (uint)Keys.Apps && keyAppsDown)
287291
{
288292
if (config.UseMenuKey)
@@ -300,7 +304,11 @@ private static bool kbdHook_KeyUpEvent(llc.KeyboardHook sender, uint vkCode, boo
300304
}
301305
}
302306
else if (vkCode >= (uint)Keys.D0 && vkCode <= (uint)Keys.D9 && keyConfigDown)
307+
{
303308
keyConfigDown = false;
309+
if (!llc.Keyboard.IsKeyDown((int)Keys.Menu))
310+
llc.Keyboard.SendKey((int)Keys.Escape);
311+
}
304312
return false;
305313
}
306314
private static String GetCommonPrefix(String s1, String s2)

0 commit comments

Comments
 (0)