AutoHotKey将剪贴板转换为键盘输入用于VNC

看到有人求助 VNC 中无法粘贴.

在 google 上搜索了一下, 找到一个这样的结果
https://ardalis.com/use-autohotkey-to-paste-text-as-typing/
#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Event  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

setkeydelay 70

^+v::GoTo, CMD

CMD:
;Send {Raw}%Clipboard%
vText := Clipboard
Clipboard := vText
Loop Parse, vText, % "`n", % "`r"
{
    Send, % "{Text}" A_LoopField
    Send, % "+{Enter}"
}
return
试用了一下, 效果不对.
但是 AutoHotKey 这个思路是对的.
所以让GPT写了一个.
#F3::
; 快速键 win + f3

    TextToSend := Clipboard
    ; 检查剪贴板是否为空
    if (TextToSend = "") {
        MsgBox, clipboard empty
        Return
    }
    
    DelayMs := 500 ; 设置您想要的延迟时间(毫秒)
    
    ; 调用自定义函数发送文本
    SendTextWithDelay(TextToSend, DelayMs) 
    
    MsgBox, input finished
    Return


; ------------------------------------------------
; 自定义函数:使用 SendInput 逐字符发送,并加入 Sleep 延迟
; ------------------------------------------------
SendTextWithDelay(Text, Delay)
{
    ; 在发送字符之前 先延迟1秒
    Sleep, 1000

    ; 循环遍历文本中的每个字符
    Loop, Parse, Text
    {
        ; A_LoopField 包含当前循环中的单个字符
        SendInput, %A_LoopField%
        
        ; 强制等待指定的毫秒数
        Sleep, %Delay%
    }
}

使用效果演示

最后, 如果你也希望帮助翻墙新手, 欢迎关注这个关键字通知频道!


评论

The Hot3 in Last 7 Days

隐形眼镜 的 包装 和 直径 对使用的影响

RackNerd VPS搭Xray Reality梯子 年付 $10.98 1G端口 3T流量 17G存储 1GB内存

商业化电报关键词提醒机器人 telegram keyword monitor bot