好友
阅读权限10
听众
最后登录1970-1-1
|
不知道大家有没有遇到过这样的场景 ,就是批量发送评价或者在游戏中随机发送文字。
正好我今天遇见了,于是写了一个,界面很简单就是加载一个文本文件的选择框,一个随机模式复选框(如果不勾选 则会顺序发送),一个是否在粘贴后自动按下回车发送的复选框。
没有设置修改快捷键的功能,默认F1。需要改的在下面回帖或者自己去改源码吧。(ahk编写)
主要功能就是从加载的文本文件中选一行,粘贴进当前的输入框。
下载地址
https://wwyn.lanzout.com/iv4YX2qr469a
脚本如下:
; 初始化配置
#SingleInstance Force
#NoEnv
SetWorkingDir %A_ScriptDir%
global currentMode := 1 ; 1=随机模式,0=顺序模式
global autoEnter := 0
global dataPath := A_ScriptDir "\data.txt"
global currentIndex := 1
; 加载配置
IniRead, savedDataPath, settings.ini, config, dataPath, %dataPath%
IniRead, savedMode, settings.ini, config, mode, 1
IniRead, savedAutoEnter, settings.ini, config, autoenter, 0
; 创建GUI
Gui, +AlwaysOnTop +OwnDialogs
Gui, Font, s10
; 文件选择按钮
UpdateFileDisplay()
Gui, Add, Button, x10 y10 w180 h30 gSelectFile vFileButton, %currentFileDisplay%
; 功能选项
Gui, Add, Checkbox, x10 y50 vRandomMode Checked%currentMode% gUpdateMode, 随机模式
Gui, Add, Checkbox, x100 y50 vAutoEnter Checked%autoEnter% gUpdateAutoEnter, 自动回车
Gui, Add, Text, x10 y80 w180 Center, 按 F1 键粘贴内容
Gui, Show, w200 h120, 文本助手
; 应用配置
ApplyConfig()
return
;========= 核心功能 =========
F1::
if !FileExist(dataPath) {
MsgBox 0x40010, 错误, 请先选择有效文件!
return
}
file := FileOpen(dataPath, "r", "UTF-8")
content := file.Read()
file.Close()
; 统一换行符
content := StrReplace(content, "`r", "")
lines := StrSplit(content, "`n")
; 过滤空行
filtered := []
for _, line in lines {
if (Trim(line) != "")
filtered.Push(Trim(line))
}
if !filtered.Length() {
MsgBox 0x40010, 错误, 文件内容为空!
return
}
; 选择内容逻辑
if (currentMode) {
Random, index, 1, filtered.Length()
} else {
index := currentIndex
currentIndex := (currentIndex >= filtered.Length()) ? 1 : currentIndex + 1
}
; 执行粘贴
Clipboard := filtered[index]
Send ^v
if (autoEnter)
Send {Enter}
return
;========= 配置函数 =========
ApplyConfig() {
global
dataPath := FileExist(savedDataPath) ? savedDataPath : dataPath
currentMode := savedMode is digit ? savedMode : 1 ; 修复配置类型问题
autoEnter := savedAutoEnter
currentIndex := 1
UpdateFileDisplay()
}
UpdateFileDisplay() {
global dataPath
SplitPath, dataPath, fileName
currentFileDisplay := fileName ? fileName : "点击选择文件"
GuiControl, , FileButton, 当前文件:%currentFileDisplay%
}
;========= 事件响应 =========
SelectFile:
FileSelectFile, selectedFile, 3, %A_ScriptDir%, 选择文本文件, *.txt
if selectedFile {
dataPath := selectedFile
IniWrite, %dataPath%, settings.ini, config, dataPath
UpdateFileDisplay()
currentIndex := 1 ; 切换文件时重置顺序索引
}
return
UpdateMode:
Gui, Submit, NoHide
currentMode := RandomMode ; 直接使用复选框的布尔值
IniWrite, %currentMode%, settings.ini, config, mode
if !currentMode ; 切换到顺序模式时重置索引
currentIndex := 1
return
UpdateAutoEnter:
Gui, Submit, NoHide
IniWrite, %autoEnter%, settings.ini, config, autoenter
return
GuiClose:
ExitApp
|
免费评分
-
查看全部评分
|