Add desktop input mode switch
This commit is contained in:
@@ -2,6 +2,12 @@ namespace WirelessTextSyncer.Windows.Services;
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
public enum TextInjectionMode
|
||||
{
|
||||
ClipboardPaste,
|
||||
SendInputTyping
|
||||
}
|
||||
|
||||
public sealed class KeyboardInjectionService : IKeyboardInjectionService
|
||||
{
|
||||
private const uint InputKeyboard = 1;
|
||||
@@ -16,6 +22,8 @@ public sealed class KeyboardInjectionService : IKeyboardInjectionService
|
||||
private const ushort VirtualKeyV = 0x56;
|
||||
private static readonly IntPtr EnglishKeyboardLayout = LoadKeyboardLayout("00000409", KlfActivate);
|
||||
|
||||
public TextInjectionMode Mode { get; set; } = TextInjectionMode.ClipboardPaste;
|
||||
|
||||
public void InsertText(string text)
|
||||
{
|
||||
if (string.IsNullOrEmpty(text))
|
||||
@@ -23,7 +31,13 @@ public sealed class KeyboardInjectionService : IKeyboardInjectionService
|
||||
return;
|
||||
}
|
||||
|
||||
AppLogger.Info($"Pasting text length: {text.Length}");
|
||||
AppLogger.Info($"Inserting text length: {text.Length}. Mode: {Mode}.");
|
||||
if (Mode == TextInjectionMode.SendInputTyping)
|
||||
{
|
||||
TypeTextWithSendInput(text);
|
||||
return;
|
||||
}
|
||||
|
||||
PasteTextViaClipboard(text);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user