阅读:44回复:2

AutoHotkey v2 Script辅助输入脚本

楼主#
更多 发布于:2026-01-09 18:29
使用环境:windows
前提有autohotkey坏境,autohotkey有绿色免安装版本,大小为3M。
下载地址为:https://www.autohotkey.com/download/
如何安装 AutoHotkey参考:https://wyagd001.github.io/v2/docs/howto/Install.htm
程序的使用:https://wyagd001.github.io/v2/docs/Program.htm
沙发#
发布于:2026-01-09 18:34
仿在wps表格中按组合键ctrl+;输入日期,ctrl+shift+;输入时间。脚本如下
^;::
{
currentDateTime := A_Now
formatteDate := FormatTime(currentDateTime, "yyyy/M/d")
send formatteDate
}
^+;::
{
currentDateTime := A_Now
formatteTime := FormatTime(currentDateTime, "HH:mm")
send formatteTime
}
板凳#
发布于:2026-01-11 01:22
重新启动小小输入法,用于让修改后的配置文件快速生效
TargetProcessName := "yong.exe"
TargetExePath := "d:\yong\w64\yong.exe"
if !FileExist(TargetExePath) {
    MsgBox "错误:未找到目标程序文件。`n路径: " TargetExePath
    ExitApp
}
try {
    pid := ProcessExist(TargetProcessName)
    if (pid = 0) {
        Run TargetExePath
    } else {
run "taskkill /im yong.exe"
        MaxWaitTime := 10000 ; 最多等待10秒
        StartTime := A_TickCount
        while ProcessExist(pid) {
            if (A_TickCount - StartTime > MaxWaitTime) {
                if MsgBox("程序关闭超时,是否强制终止?", "警告", "YesNo Icon!") = "Yes" {
                    ProcessClose pid ; 强制终止进程
                    Sleep 500 ; 稍等片刻让系统处理
                } else {
                    MsgBox "用户取消操作。"
                    ExitApp
                }
                break ; 退出循环
            }
            Sleep 500 ; 每500毫秒检查一次,避免CPU占用过高
        }
        if !ProcessExist(TargetProcessName) {
            Run TargetExePath
        } else {
            MsgBox "无法启动新实例,旧进程可能仍在运行。"
        }
    }
} catch as e {
    MsgBox "在操作过程中发生错误:`n" e.Message, "错误", "Iconx"
}
游客

返回顶部