Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

feat(windows): add native fast-paste binary with terminal detection (#229)

Gabriel Stein91b131e0c929
diff --git a/.github/workflows/build-windows-fast-paste.yml b/.github/workflows/build-windows-fast-paste.yml
new file mode 100644
index 000000000..877a559f8
--- /dev/null
+++ b/.github/workflows/build-windows-fast-paste.yml
@@ -0,0 +1,73 @@
+name: Build Windows Fast Paste
+
+on:
+ push:
+ paths:
+ - 'resources/windows-fast-paste.c'
+ - '.github/workflows/build-windows-fast-paste.yml'
+ branches:
+ - main
+ workflow_dispatch:
+ inputs:
+ version:
+ description: 'Version tag (e.g., 1.0.0)'
+ required: false
+ default: '1.0.0'
+ type: string
+
+permissions:
+ contents: write
+
+jobs:
+ build:
+ runs-on: windows-latest
+ steps:
+ - uses: actions/checkout@v4
+
+ - name: Setup MSVC
+ uses: microsoft/setup-msbuild@v2
+
+ - name: Setup MSVC environment
+ uses: ilammy/msvc-dev-cmd@v1
+
+ - name: Compile Windows Fast Paste
+ run: |
+ cl /O2 /nologo resources/windows-fast-paste.c /Fe:windows-fast-paste.exe user32.lib
+ shell: cmd
+
+ - name: Verify binary
+ run: |
+ if (Test-Path "windows-fast-paste.exe") {
+ Write-Host "Binary built successfully"
+ Get-Item "windows-fast-paste.exe" | Select-Object Name, Length
+ } else {
+ Write-Error "Binary not found"
+ exit 1
+ }
+ shell: pwsh
+
+ - name: Create zip archive
+ run: |
+ Compress-Archive -Path windows-fast-paste.exe -DestinationPath windows-fast-paste-win32-x64.zip
+ shell: pwsh
+
+ - name: Upload artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: windows-fast-paste
+ path: windows-fast-paste-win32-x64.zip
+
+ - name: Create or update release
+ uses: softprops/action-gh-release@v2
+ with:
+ tag_name: windows-fast-paste-v${{ inputs.version || '1.0.0' }}
+ name: Windows Fast Paste v${{ inputs.version || '1.0.0' }}
+ body: |
+ Prebuilt Windows fast-paste binary for clipboard paste operations.
+
+ Uses Win32 SendInput API with automatic terminal detection
+ (Ctrl+V for normal apps, Ctrl+Shift+V for terminals).
+ files: windows-fast-paste-win32-x64.zip
+ make_latest: false
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/electron-builder.json b/electron-builder.json
index c762020d7..130827c52 100644
--- a/electron-builder.json
+++ b/electron-builder.json
@@ -97,6 +97,7 @@
"llama-server-*",
"sherpa-onnx-*",
"windows-key-listener*",
+ "windows-fast-paste*",
"*.dylib",
"*.dll",
"*.so*"
diff --git a/package.json b/package.json
index c1ac41e7c..009953c0c 100644
--- a/package.json
+++ b/package.json
@@ -8,8 +8,9 @@
"compile:globe": "node scripts/build-globe-listener.js",
"compile:fast-paste": "node scripts/build-macos-fast-paste.js",
"compile:winkeys": "node scripts/build-windows-key-listener.js",
+ "compile:winpaste": "node scripts/build-windows-fast-paste.js",
"compile:linux-paste": "node scripts/build-linux-fast-paste.js",
- "compile:native": "npm run compile:globe && npm run compile:fast-paste && npm run compile:winkeys && npm run compile:linux-paste",
+ "compile:native": "npm run compile:globe && npm run compile:fast-paste && npm run compile:winkeys && npm run compile:winpaste && npm run compile:linux-paste",
"prestart": "npm run compile:native",
"start": "electron .",
"predev": "npm run compile:native",
diff --git a/resources/windows-fast-paste.c b/resources/windows-fast-paste.c
new file mode 100644
index 000000000..7e72118b2
--- /dev/null
+++ b/resources/windows-fast-paste.c
@@ -0,0 +1,142 @@
+/**
+ * Windows Fast Paste for OpenWhispr
+ *
+ * Detects the foreground window, checks if it's a terminal emulator,
+ * and simulates the appropriate paste keystroke using Win32 SendInput:
+ * - Ctrl+V for normal applications
+ * - Ctrl+Shift+V for terminal emulators
+ *
+ * Compile with: cl /O2 windows-fast-paste.c /Fe:windows-fast-paste.exe user32.lib
+ * Or with MinGW: gcc -O2 windows-fast-paste.c -o windows-fast-paste.exe -luser32
+ */
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <stdio.h>
+#include <string.h>
+
+static const char* TERMINAL_CLASSES[] = {
+ "ConsoleWindowClass",
+ "CASCADIA_HOSTING_WINDOW_CLASS",
+ "mintty",
+ "VirtualConsoleClass",
+ "PuTTY",
+ "Alacritty",
+ "org.wezfurlong.wezterm",
+ "Hyper",
+ "TMobaXterm",
+ NULL
+};
+
+static BOOL IsTerminalClass(const char* className) {
+ for (int i = 0; TERMINAL_CLASSES[i] != NULL; i++) {
+ if (_stricmp(className, TERMINAL_CLASSES[i]) == 0) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+static int SendPasteNormal(void) {
+ INPUT inputs[4];
+ ZeroMemory(inputs, sizeof(inputs));
+
+ inputs[0].type = INPUT_KEYBOARD;
+ inputs[0].ki.wVk = VK_CONTROL;
+
+ inputs[1].type = INPUT_KEYBOARD;
+ inputs[1].ki.wVk = 'V';
+
+ inputs[2].type = INPUT_KEYBOARD;
+ inputs[2].ki.wVk = 'V';
+ inputs[2].ki.dwFlags = KEYEVENTF_KEYUP;
+
+ inputs[3].type = INPUT_KEYBOARD;
+ inputs[3].ki.wVk = VK_CONTROL;
+ inputs[3].ki.dwFlags = KEYEVENTF_KEYUP;
+
+ UINT sent = SendInput(4, inputs, sizeof(INPUT));
+ return (sent == 4) ? 0 : 1;
+}
+
+static int SendPasteTerminal(void) {
+ INPUT inputs[6];
+ ZeroMemory(inputs, sizeof(inputs));
+
+ inputs[0].type = INPUT_KEYBOARD;
+ inputs[0].ki.wVk = VK_CONTROL;
+
+ inputs[1].type = INPUT_KEYBOARD;
+ inputs[1].ki.wVk = VK_SHIFT;
+
+ inputs[2].type = INPUT_KEYBOARD;
+ inputs[2].ki.wVk = 'V';
+
+ inputs[3].type = INPUT_KEYBOARD;
+ inputs[3].ki.wVk = 'V';
+ inputs[3].ki.dwFlags = KEYEVENTF_KEYUP;
+
+ inputs[4].type = INPUT_KEYBOARD;
+ inputs[4].ki.wVk = VK_SHIFT;
+ inputs[4].ki.dwFlags = KEYEVENTF_KEYUP;
+
+ inputs[5].type = INPUT_KEYBOARD;
+ inputs[5].ki.wVk = VK_CONTROL;
+ inputs[5].ki.dwFlags = KEYEVENTF_KEYUP;
+
+ UINT sent = SendInput(6, inputs, sizeof(INPUT));
+ return (sent == 6) ? 0 : 1;
+}
+
+int main(int argc, char* argv[]) {
+ BOOL detectOnly = FALSE;
+
+ for (int i = 1; i < argc; i++) {
+ if (strcmp(argv[i], "--detect-only") == 0) {
+ detectOnly = TRUE;
+ }
+ }
+
+ HWND hwnd = GetForegroundWindow();
+ if (!hwnd) {
+ fprintf(stderr, "ERROR: No foreground window found\n");
+ return 2;
+ }
+
+ char className[256];
+ int classLen = GetClassNameA(hwnd, className, sizeof(className));
+ if (classLen == 0) {
+ fprintf(stderr, "ERROR: Could not get window class name (error %lu)\n", GetLastError());
+ return 1;
+ }
+
+ BOOL isTerminal = IsTerminalClass(className);
+
+ if (detectOnly) {
+ printf("WINDOW_CLASS %s\n", className);
+ printf("IS_TERMINAL %s\n", isTerminal ? "true" : "false");
+ fflush(stdout);
+ return 0;
+ }
+
+ Sleep(5);
+
+ int result;
+ if (isTerminal) {
+ result = SendPasteTerminal();
+ } else {
+ result = SendPasteNormal();
+ }
+
+ if (result != 0) {
+ fprintf(stderr, "ERROR: SendInput failed (error %lu)\n", GetLastError());
+ return 1;
+ }
+
+ Sleep(20);
+
+ printf("PASTE_OK %s %s\n", className, isTerminal ? "ctrl+shift+v" : "ctrl+v");
+ fflush(stdout);
+
+ return 0;
+}
diff --git a/scripts/build-windows-fast-paste.js b/scripts/build-windows-fast-paste.js
new file mode 100644
index 000000000..50fa0e78d
--- /dev/null
+++ b/scripts/build-windows-fast-paste.js
@@ -0,0 +1,187 @@
+#!/usr/bin/env node
+/**
+ * Ensures the Windows fast-paste binary is available.
+ *
+ * Strategy:
+ * 1. If binary exists and is up-to-date, do nothing
+ * 2. Try to download prebuilt binary from GitHub releases
+ * 3. Fall back to local compilation if download fails
+ *
+ * This allows developers without a C compiler to still build the app.
+ */
+
+const { spawnSync } = require("child_process");
+const fs = require("fs");
+const path = require("path");
+
+const isWindows = process.platform === "win32";
+if (!isWindows) {
+ // Only needed on Windows
+ process.exit(0);
+}
+
+const projectRoot = path.resolve(__dirname, "..");
+const cSource = path.join(projectRoot, "resources", "windows-fast-paste.c");
+const outputDir = path.join(projectRoot, "resources", "bin");
+const outputBinary = path.join(outputDir, "windows-fast-paste.exe");
+
+function log(message) {
+ console.log(`[windows-fast-paste] ${message}`);
+}
+
+function ensureDir(dirPath) {
+ if (!fs.existsSync(dirPath)) {
+ fs.mkdirSync(dirPath, { recursive: true });
+ }
+}
+
+function isBinaryUpToDate() {
+ if (!fs.existsSync(outputBinary)) {
+ return false;
+ }
+
+ if (!fs.existsSync(cSource)) {
+ return true;
+ }
+
+ try {
+ const binaryStat = fs.statSync(outputBinary);
+ const sourceStat = fs.statSync(cSource);
+ return binaryStat.mtimeMs >= sourceStat.mtimeMs;
+ } catch {
+ return false;
+ }
+}
+
+async function tryDownload() {
+ log("Attempting to download prebuilt binary...");
+
+ const downloadScript = path.join(__dirname, "download-windows-fast-paste.js");
+ if (!fs.existsSync(downloadScript)) {
+ log("Download script not found, skipping download");
+ return false;
+ }
+
+ const result = spawnSync(process.execPath, [downloadScript, "--force"], {
+ stdio: "inherit",
+ cwd: projectRoot,
+ });
+
+ if (result.status === 0 && fs.existsSync(outputBinary)) {
+ log("Successfully downloaded prebuilt binary");
+ return true;
+ }
+
+ log("Download failed or binary not found after download");
+ return false;
+}
+
+/**
+ * Quote a path for use in shell commands on Windows.
+ * @param {string} p - Path to quote
+ * @returns {string} - Quoted path safe for shell use
+ */
+function quotePath(p) {
+ return `"${p.replace(/"/g, '\\"')}"`;
+}
+
+function tryCompile() {
+ if (!fs.existsSync(cSource)) {
+ log("C source not found, cannot compile locally");
+ return false;
+ }
+
+ log("Attempting local compilation...");
+
+ const compilers = [
+ {
+ name: "MSVC",
+ check: { command: "cl", args: [] },
+ useShell: true,
+ getCommand: () =>
+ `cl /O2 /nologo ${quotePath(cSource)} /Fe:${quotePath(outputBinary)} user32.lib`,
+ },
+ {
+ name: "MinGW-w64",
+ check: { command: "gcc", args: ["--version"] },
+ useShell: false,
+ command: "gcc",
+ args: ["-O2", cSource, "-o", outputBinary, "-luser32"],
+ },
+ {
+ name: "Clang",
+ check: { command: "clang", args: ["--version"] },
+ useShell: false,
+ command: "clang",
+ args: ["-O2", cSource, "-o", outputBinary, "-luser32"],
+ },
+ ];
+
+ for (const compiler of compilers) {
+ log(`Trying ${compiler.name}...`);
+
+ const checkResult = spawnSync(compiler.check.command, compiler.check.args, {
+ stdio: "pipe",
+ shell: true,
+ });
+
+ if (checkResult.status !== 0 && checkResult.error) {
+ log(`${compiler.name} not found, trying next...`);
+ continue;
+ }
+
+ let result;
+ if (compiler.useShell) {
+ const cmd = compiler.getCommand();
+ log(`Compiling with: ${cmd}`);
+ result = spawnSync(cmd, [], {
+ stdio: "inherit",
+ cwd: projectRoot,
+ shell: true,
+ });
+ } else {
+ log(`Compiling with: ${compiler.command} ${compiler.args.join(" ")}`);
+ result = spawnSync(compiler.command, compiler.args, {
+ stdio: "inherit",
+ cwd: projectRoot,
+ shell: false,
+ });
+ }
+
+ if (result.status === 0 && fs.existsSync(outputBinary)) {
+ log(`Successfully built with ${compiler.name}`);
+ return true;
+ }
+
+ log(`${compiler.name} compilation failed, trying next...`);
+ }
+
+ return false;
+}
+
+async function main() {
+ ensureDir(outputDir);
+
+ if (isBinaryUpToDate()) {
+ log("Binary is up to date, skipping build");
+ return;
+ }
+
+ const downloaded = await tryDownload();
+ if (downloaded) {
+ return;
+ }
+
+ const compiled = tryCompile();
+ if (compiled) {
+ return;
+ }
+
+ console.warn("[windows-fast-paste] Could not obtain Windows fast-paste binary.");
+ console.warn("[windows-fast-paste] Windows paste will use nircmd/PowerShell fallback.");
+}
+
+main().catch((error) => {
+ console.error("[windows-fast-paste] Unexpected error:", error);
+ // Don't fail the build
+});
diff --git a/scripts/download-windows-fast-paste.js b/scripts/download-windows-fast-paste.js
new file mode 100644
index 000000000..0901a42e1
--- /dev/null
+++ b/scripts/download-windows-fast-paste.js
@@ -0,0 +1,108 @@
+#!/usr/bin/env node
+/**
+ * Downloads prebuilt Windows fast-paste binary from GitHub releases.
+ * Used for terminal-aware clipboard paste on Windows.
+ *
+ * Usage:
+ * node scripts/download-windows-fast-paste.js [--force]
+ *
+ * Options:
+ * --force Re-download even if binary already exists
+ */
+
+const fs = require("fs");
+const path = require("path");
+const { downloadFile, extractZip, fetchLatestRelease, setExecutable } = require("./lib/download-utils");
+
+const REPO = "OpenWhispr/openwhispr";
+const TAG_PREFIX = "windows-fast-paste-v";
+const ZIP_NAME = "windows-fast-paste-win32-x64.zip";
+const BINARY_NAME = "windows-fast-paste.exe";
+
+const VERSION_OVERRIDE = process.env.WINDOWS_FAST_PASTE_VERSION || null;
+
+const BIN_DIR = path.join(__dirname, "..", "resources", "bin");
+
+async function main() {
+ if (process.platform !== "win32") {
+ console.log("[windows-fast-paste] Skipping download (not Windows)");
+ return;
+ }
+
+ const forceDownload = process.argv.includes("--force");
+ const outputPath = path.join(BIN_DIR, BINARY_NAME);
+
+ if (fs.existsSync(outputPath) && !forceDownload) {
+ console.log("[windows-fast-paste] Already exists (use --force to re-download)");
+ console.log(` ${outputPath}`);
+ return;
+ }
+
+ if (VERSION_OVERRIDE) {
+ console.log(`\n[windows-fast-paste] Using pinned version: ${VERSION_OVERRIDE}`);
+ } else {
+ console.log("\n[windows-fast-paste] Fetching latest release...");
+ }
+ const tagToFind = VERSION_OVERRIDE || TAG_PREFIX;
+ const release = await fetchLatestRelease(REPO, { tagPrefix: tagToFind });
+
+ if (!release) {
+ console.error("[windows-fast-paste] Could not find a release matching prefix:", TAG_PREFIX);
+ console.log("[windows-fast-paste] Paste will use nircmd/PowerShell fallback");
+ return;
+ }
+
+ const zipAsset = release.assets.find((a) => a.name === ZIP_NAME);
+ if (!zipAsset) {
+ console.error(`[windows-fast-paste] Release ${release.tag} does not contain ${ZIP_NAME}`);
+ console.log("[windows-fast-paste] Available assets:", release.assets.map((a) => a.name).join(", "));
+ return;
+ }
+
+ console.log(`\nDownloading Windows fast-paste (${release.tag})...\n`);
+
+ fs.mkdirSync(BIN_DIR, { recursive: true });
+
+ const zipPath = path.join(BIN_DIR, ZIP_NAME);
+ console.log(` Downloading from: ${zipAsset.url}`);
+
+ try {
+ await downloadFile(zipAsset.url, zipPath);
+
+ const extractDir = path.join(BIN_DIR, "temp-windows-fast-paste");
+ fs.mkdirSync(extractDir, { recursive: true });
+
+ console.log(" Extracting...");
+ extractZip(zipPath, extractDir);
+
+ const binaryPath = path.join(extractDir, BINARY_NAME);
+ if (fs.existsSync(binaryPath)) {
+ fs.copyFileSync(binaryPath, outputPath);
+ setExecutable(outputPath);
+ console.log(` Extracted to: ${BINARY_NAME}`);
+ } else {
+ throw new Error(`Binary not found in archive: ${BINARY_NAME}`);
+ }
+
+ fs.rmSync(extractDir, { recursive: true, force: true });
+ if (fs.existsSync(zipPath)) {
+ fs.unlinkSync(zipPath);
+ }
+
+ const stats = fs.statSync(outputPath);
+ console.log(`\n[windows-fast-paste] Successfully downloaded ${release.tag} (${Math.round(stats.size / 1024)}KB)`);
+ } catch (error) {
+ console.error(`\n[windows-fast-paste] Download failed: ${error.message}`);
+
+ if (fs.existsSync(zipPath)) {
+ fs.unlinkSync(zipPath);
+ }
+
+ console.log("[windows-fast-paste] Paste will use nircmd/PowerShell fallback");
+ }
+}
+
+main().catch((error) => {
+ console.error("[windows-fast-paste] Unexpected error:", error);
+ // Don't fail the build
+});
diff --git a/src/helpers/clipboard.js b/src/helpers/clipboard.js
index 499913619..4275127d6 100644
--- a/src/helpers/clipboard.js
+++ b/src/helpers/clipboard.js
@@ -46,6 +46,7 @@ const getLinuxSessionInfo = () => {
const PASTE_DELAYS = {
darwin: 120,
+ win32_fast: 10,
win32_nircmd: 30,
win32_pwsh: 40,
linux: 50,
@@ -74,6 +75,8 @@ class ClipboardManager {
this.nircmdChecked = false;
this.fastPastePath = null;
this.fastPasteChecked = false;
+ this.winFastPastePath = null;
+ this.winFastPasteChecked = false;
this.linuxFastPastePath = null;
this.linuxFastPasteChecked = false;
}
@@ -199,6 +202,15 @@ class ClipboardManager {
);
}
+ resolveWindowsFastPasteBinary() {
+ return this._resolveNativeBinary(
+ "windows-fast-paste.exe",
+ "win32",
+ "winFastPasteChecked",
+ "winFastPastePath"
+ );
+ }
+
resolveLinuxFastPasteBinary() {
return this._resolveNativeBinary(
"linux-fast-paste",
@@ -317,8 +329,13 @@ class ClipboardManager {
this.safeLog("✅ Permissions granted, attempting to paste...");
await this.pasteMacOS(originalClipboard, options);
} else if (platform === "win32") {
- const nircmdPath = this.getNircmdPath();
- method = nircmdPath ? "nircmd" : "powershell";
+ const winFastPaste = this.resolveWindowsFastPasteBinary();
+ if (winFastPaste) {
+ method = "sendinput";
+ } else {
+ const nircmdPath = this.getNircmdPath();
+ method = nircmdPath ? "nircmd" : "powershell";
+ }
await this.pasteWindows(originalClipboard);
} else {
method = this.resolveLinuxFastPasteBinary() ? "linux-xtest" : "linux-tools";
@@ -467,13 +484,92 @@ class ClipboardManager {
}
async pasteWindows(originalClipboard) {
- const nircmdPath = this.getNircmdPath();
+ const fastPastePath = this.resolveWindowsFastPasteBinary();
+
+ if (fastPastePath) {
+ return this.pasteWithFastPaste(fastPastePath, originalClipboard);
+ }
+
+ return this.pasteWithNircmdOrPowerShell(originalClipboard);
+ }
+
+ async pasteWithFastPaste(fastPastePath, originalClipboard) {
+ return new Promise((resolve, reject) => {
+ setTimeout(() => {
+ let hasTimedOut = false;
+ const startTime = Date.now();
+
+ this.safeLog("⚡ Windows fast-paste starting");
+
+ const pasteProcess = spawn(fastPastePath, [], {
+ stdio: ["ignore", "pipe", "pipe"],
+ windowsHide: true,
+ });
+
+ let stdoutData = "";
+ let stderrData = "";
+
+ pasteProcess.stdout.on("data", (data) => {
+ stdoutData += data.toString();
+ });
+
+ pasteProcess.stderr.on("data", (data) => {
+ stderrData += data.toString();
+ });
+
+ pasteProcess.on("close", (code) => {
+ if (hasTimedOut) return;
+ clearTimeout(timeoutId);
+
+ const elapsed = Date.now() - startTime;
+ const output = stdoutData.trim();
+ if (code === 0) {
+ this.safeLog("✅ Windows fast-paste success", {
+ elapsedMs: elapsed,
+ output,
+ });
+ setTimeout(() => {
+ clipboard.writeText(originalClipboard);
+ this.safeLog("🔄 Clipboard restored");
+ }, RESTORE_DELAYS.win32_nircmd);
+ resolve();
+ } else {
+ this.safeLog(
+ `❌ Windows fast-paste failed (code ${code}), falling back to nircmd/PowerShell`,
+ { elapsedMs: elapsed, stderr: stderrData.trim() }
+ );
+ this.pasteWithNircmdOrPowerShell(originalClipboard).then(resolve).catch(reject);
+ }
+ });
+
+ pasteProcess.on("error", (error) => {
+ if (hasTimedOut) return;
+ clearTimeout(timeoutId);
+ this.safeLog("❌ Windows fast-paste error, falling back to nircmd/PowerShell", {
+ elapsedMs: Date.now() - startTime,
+ error: error.message,
+ });
+ this.pasteWithNircmdOrPowerShell(originalClipboard).then(resolve).catch(reject);
+ });
+
+ const timeoutId = setTimeout(() => {
+ hasTimedOut = true;
+ this.safeLog("⏱️ Windows fast-paste timeout, falling back to nircmd/PowerShell");
+ killProcess(pasteProcess, "SIGKILL");
+ pasteProcess.removeAllListeners();
+ this.pasteWithNircmdOrPowerShell(originalClipboard).then(resolve).catch(reject);
+ }, 2000);
+ }, PASTE_DELAYS.win32_fast);
+ });
+ }
+
+ async pasteWithNircmdOrPowerShell(originalClipboard) {
+ const nircmdPath = this.getNircmdPath();
if (nircmdPath) {
return this.pasteWithNircmd(nircmdPath, originalClipboard);
- } else {
- return this.pasteWithPowerShell(originalClipboard);
}
+ return this.pasteWithPowerShell(originalClipboard);
}
async pasteWithNircmd(nircmdPath, originalClipboard) {
@@ -893,8 +989,11 @@ class ClipboardManager {
);
}
- // Use key names for ydotool 0.1.x compat (Ubuntu ships 0.1.8)
- const ydotoolArgs = inTerminal ? ["key", "ctrl+shift+v"] : ["key", "ctrl+v"];
+ // Raw keycodes work across both ydotool 0.1.x and 1.0.x (key names silently fail on 1.0.x)
+ // 29 = KEY_LEFTCTRL, 42 = KEY_LEFTSHIFT, 47 = KEY_V
+ const ydotoolArgs = inTerminal
+ ? ["key", "29:1", "42:1", "47:1", "47:0", "42:0", "29:0"]
+ : ["key", "29:1", "47:1", "47:0", "29:0"];
const wtypeEntry = canUseWtype
? [
@@ -1314,11 +1413,13 @@ Would you like to open System Settings now?`;
}
if (platform === "win32") {
+ const winFastPaste = this.resolveWindowsFastPasteBinary();
return {
platform: "win32",
available: true,
- method: "powershell",
+ method: winFastPaste ? "sendinput" : "powershell",
requiresPermission: false,
+ terminalAware: !!winFastPaste,
tools: [],
};
}
diff --git a/src/types/electron.ts b/src/types/electron.ts
index 7008b4c6f..f6572dfa1 100644
--- a/src/types/electron.ts
+++ b/src/types/electron.ts
@@ -162,6 +162,7 @@ export interface PasteToolsResult {
requiresPermission: boolean;
isWayland?: boolean;
xwaylandAvailable?: boolean;
+ terminalAware?: boolean;
hasNativeBinary?: boolean;
hasUinput?: boolean;
tools?: string[];