metalvest
2023-04-08 07:21:49 +08:00
没装 ahk 也可以用 powershell 脚本,就是有个黑窗口
Add-Type -AssemblyName System.Windows.Forms
$filePath = "C:\path\to\your\file.txt" # 替换为实际的文件路径
# 定义快捷键 Ctrl+Shift+S
$global:ctrlShiftS = [System.Windows.Forms.Keys]::S -bor `
[System.Windows.Forms.Keys]::Shift -bor `
[System.Windows.Forms.Keys]::Control
Register-ObjectEvent -InputObject $(Get-Process -Id $PID) `
-EventName KeyDown -Action {
param($sender, $eventArgs)
if ($eventArgs.KeyCode -eq $ctrlShiftS) {
$selectedText = [System.Windows.Forms.Clipboard]::GetText()
Add-Content -Path $filePath -Value $selectedText
}
} -SourceIdentifier "Hotkey"
# 持续运行脚本
while ($true) { Start-Sleep -Seconds 1 }