-- ===== 卡密验证 ===== function checkLicense() while true do local input = gg.prompt( {"请输入卡密:"}, {[1]=""}, {[1]="text"} ) -- 点取消 / 关闭面板直接退出 if input == nil then gg.toast("已取消,脚本退出") return false end -- 卡密正确 if input[1] == "123" then gg.toast("卡密验证成功") return true end -- 卡密错误,提示后重新输入 gg.alert("卡密错误,请重新输入!") end end -- ===== 进程选择 ===== function chooseProcess() local ok, procs = pcall(gg.getProcesses) if not ok or procs == nil or #procs == 0 then local pkg = gg.getTargetPackage() or "(未选择)" local confirm = gg.alert( "当前目标进程:\n" .. pkg .. "\n\n" .. "请在 GameGuardian 悬浮窗中确认/切换目标应用后再继续。\n" .. "点「继续」开始脚本,点「退出」结束。", "继续", "退出" ) return confirm == 1 end local list = {} for i, p in ipairs(procs) do list[i] = p.name .. " [PID: " .. p.pid .. "]" end local choice = gg.choice(list, nil, "请选择要修改的应用进程") if choice == nil then return false end local switched = pcall(function() gg.setProcess(procs[choice].pid) end) if switched then gg.toast("已选择: " .. procs[choice].name) else gg.alert( "请在 GameGuardian 悬浮窗中手动切换到:\n" .. procs[choice].name .. "\n\n" .. "切换完成后再点「继续」。", "继续" ) end return true end -- ===== 主流程 ===== function main() -- 第一步:卡密验证 if not checkLicense() then return end -- 第二步:选择进程 if not chooseProcess() then gg.toast("脚本已退出") return end -- 第三步:循环替换文本 while true do local prompt = gg.prompt( {"请输入要搜索的旧文本:", "请输入要替换的新文本:"}, {[1]="", [2]=""}, {[1]="text", [2]="text"} ) if prompt == nil then gg.toast("脚本已退出") return end local oldText = prompt[1] local newText = prompt[2] if oldText == "" or newText == "" then gg.toast("文本不能为空,请重新输入") else gg.setRanges( gg.REGION_JAVA_HEAP | gg.REGION_C_HEAP | gg.REGION_C_ALLOC | gg.REGION_C_DATA | gg.REGION_C_BSS | gg.REGION_PPSSPP | gg.REGION_ANONYMOUS ) gg.clearResults() gg.searchNumber(";" .. oldText, gg.TYPE_UNICODE) local count = gg.getResultsCount() if count == 0 then gg.toast("未找到: " .. oldText) else gg.getResults(count) gg.editAll(";" .. newText, gg.TYPE_WORD) gg.toast("成功替换 " .. count .. " 处") end gg.clearResults() end end end main()