13 lines
360 B
TypeScript
13 lines
360 B
TypeScript
import { execSync } from 'child_process';
|
|
|
|
export function readClipboard(): string {
|
|
try {
|
|
return execSync('powershell -command "Get-Clipboard"', { encoding: 'utf-8' }).trim();
|
|
} catch {
|
|
return '';
|
|
}
|
|
}
|
|
|
|
export function writeClipboard(text: string): void {
|
|
execSync(`powershell -command "Set-Clipboard -Value '${text.replace(/'/g, "''")}'"`);
|
|
}
|