吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1598|回复: 23
收起左侧

[原创工具] Win F1~F12 快捷键回复

  [复制链接]
sobani 发表于 2025-3-31 16:42
由于有需要 多次回复重复内容的需求
所以开发了此软件(基于AHK)
第一次发布有不足还望指点
不甚感激
#Requires AutoHotkey v2.0
#SingleInstance Force

configFile := A_ScriptDir "\sobani.ini"

configGui := Gui(, "www.52pojie.cn-sobani")
configGui.SetFont("s10", "Microsoft YaHei")

texts := []  ; 存储每个 F1-F12 的文本
edits := []  ; 存储 GUI 输入框

Loop 12 {
    key := "F" A_Index
    texts.Push(IniRead(configFile, "Hotkeys", key, ""))
}

; 创建 12 个输入框
Loop 12 {
    row := Ceil(A_Index / 4)
    col := Mod(A_Index - 1, 4) + 1

    xPos := 20 + (col - 1) * 180
    yPos := 30 + (row - 1) * 40

    configGui.Add("Text", "x" xPos " y" yPos - 15 " w160", "F" A_Index " 文本:")
    edits.Push(configGui.Add("Edit", "x" xPos " y" yPos " w160 h25", texts[A_Index]))
}

; 添加复选框:是否自动回车
autoEnter := IniRead(configFile, "Settings", "AutoEnter", "0")  ; 读取配置
autoEnterCheck := configGui.Add("CheckBox", "x150 y155 w250", "自动回车 (发送文本后按 Enter)")
autoEnterCheck.Value := autoEnter  ; 设定复选框状态

; 添加保存按钮
configGui.Add("Button", "x20 y150 w100 h30", "保存配置").OnEvent("Click", saveConfig)

configGui.Show("w750 h200")

; **保存配置函数**
saveConfig(*) {
    global edits, configFile, autoEnterCheck

    Loop 12 {
        key := "F" A_Index
        IniWrite(edits[A_Index].Value, configFile, "Hotkeys", key)
    }

    ; 保存自动回车选项
    IniWrite(autoEnterCheck.Value, configFile, "Settings", "AutoEnter")
    autoEnter := autoEnterCheck.Value  ; 更新全局变量

    MsgBox("配置已保存!", "成功", "Iconi T1")
    Reload  ; 重新加载脚本
}

; **✅ 绑定独立的热键,确保 F1-F12 输出各自文本**
Loop 12 {
    key := "F" A_Index
    thisText := texts[A_Index]  ; **把文本赋值到局部变量,确保每个按键独立**
    
    if thisText != "" {
        Hotkey(key, BindKey(thisText))
    }
}

; **✅ 使用独立闭包**
BindKey(text) {
    return (*) => SendWithEnter(text)  ; 发送文本并判断是否加回车
}

; **✅ 发送文本并判断是否加回车**
SendWithEnter(text) {
    global autoEnter
    SendText(text)  ; 发送文本
    if autoEnter  ; 如果开启了自动回车
        Send("{Enter}")  ; 发送回车
}

A_TrayMenu.Add()  ; 创建分隔线.
; 添加右键菜单
A_TrayMenu.Add("打开配置", OpenGui)  ; 右键菜单添加打开配置选项
A_TrayMenu.Add("切换自动回车", ToggleAutoEnter)  ; 添加切换自动回车选项
A_TrayMenu.Add("退出", ExitScript)  ; 添加退出脚本选项

Persistent

; **切换自动回车模式**
ToggleAutoEnter(*) {
    global autoEnter, configFile
    autoEnter := !autoEnter  ; 取反
    IniWrite(autoEnter, configFile, "Settings", "AutoEnter")  ; 更新配置文件
    TrayTip("", autoEnter ? "开启自动回车" : "关闭自动回车", 1)
}

; 打开 GUI 函数
OpenGui(*) {
    configGui.Show("w750 h200")  ; 显示配置界面
}

; 退出脚本函数
ExitScript(*) {
    ExitApp  ; 退出脚本
}
https://wwps.lanzouu.com/iFd2A2s8v1zg
密码:hshd
image.png

免费评分

参与人数 6吾爱币 +11 热心值 +6 收起 理由
gexiaheren + 1 + 1 谢谢@Thanks!
kw1214 + 1 + 1 谢谢@Thanks!
WXJYXLWMH + 1 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
ElEzUs + 1 + 1 我很赞同!
confiant + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
风之暇想 + 7 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

wolfsino 发表于 2025-4-5 19:06
跟这个帖子的软件有点类似
https://www.52pojie.cn/thread-1995951-1-1.html
[原创工具] 重复工作总是让人难受,快速粘贴工具,相信可以让你心情愉快!
本帖最后由 dreamscd 于 2025-3-31 14:11 编辑
dgrayman 发表于 2025-4-3 10:54
感觉开发还不如用现成的,比如易歪歪单机版 还有论坛的咕咕文本
638 发表于 2025-4-3 13:03
yao16026000 发表于 2025-4-3 15:17
非常好,对于客服的快捷回复非常核实
女王的小废物 发表于 2025-4-3 15:22
祖安狂人已上线?
qxhdly 发表于 2025-4-3 18:11
感谢分享  谢谢
userxiamenger1 发表于 2025-4-3 20:09
能快捷键回复图片更好一点
wxw162431 发表于 2025-4-3 20:25
支持原创,感谢分享。
dzy123 发表于 2025-4-3 21:43

非常不错、感谢楼主分享~~~~
流浪情人 发表于 2025-4-3 22:13
客服专用应该不错啊 哈哈哈
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-7-7 21:53

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表