我如何用 AI+ 元动作重构 Quicker C# 开发流——找回被“右键”磨灭的开发热情

洛洛罗 2025/12/22 发布 · 2025/12/22 更新 · 61 次阅读

引言:被“右键”磨灭的开发热情

每一个 Quicker 高阶玩家,最终都会走到编写 C# 脚本这一步。C# 的强大毋庸置疑,但 Quicker 原生的动作开发体验,对于习惯了 IDE 的开发者来说,有时却是一场耐心的考验。

回想一下,当你脑海中蹦出一个简单的功能想法时,你需要经历什么?

  1. 新建动作:右键 -> 新建动作。

  2. 配置 UI:起名字、找图标(这一步尤其杀时间)、写简介。

  3. 编辑流:打开编辑器 -> 拖入“C# 脚本”模块。

  4. 编写代码:在那个没有智能提示、没有代码补全的小窗口里写代码,或者在 VSCode 里写好,Ctrl+C 再 Ctrl+V 粘贴进去。

  5. 调试循环:一旦报错,就要重新点开那个小窗口,修改,保存,再试。

“我只是想写 10 行代码实现一个 API 调用,为什么要点 50 次鼠标?”

这种繁琐的 GUI 操作流,硬生生把“开发”变成了“填表”。为了找回编码的乐趣,我决定利用 AI 和 Quicker 自身的自动化能力,开发一个能“自己写动作”的元动作(Action Factory)

核心思路:代码与配置分离

要实现自动化,首先要解耦。一个 Quicker 动作本质上由两部分组成:

  1. 元数据(Metadata):动作ID、图标、标题、变量定义、步骤结构。

  2. 核心逻辑(Logic):实际运行的 C# 代码。

如果我能制定一个标准化的 JSON 模板来承载元数据,再用一个独立的 .cs 文件承载逻辑,最后写一个“编译器”把它们合并,我就能脱离 Quicker 的编辑器了。

更进一步:如果我把这个生成 JSON 和 CS 文件的任务交给 AI 呢?

解决方案:AI 驱动的“动作工厂”

我构建了一套全新的工作流:我只负责给 AI 提需求,AI 负责写代码并调用 Quicker 生成动作。

这是AI创建动作的示意:

 

这是AI生成的动作:

可以看到名称、图标和功能描述一并写好了

 

如果要修改呢?就又和AI对话,AI的提示词中说明了如何修改,修改后AI会自动调用构建起更新动作。同时返回了运行结果,不用再打开网页看调试结果再复制给AI了

真是又快又好

1. 架构图解

整个流程如下:

  1. User:向 AI (ChatGPT/Claude/DeepSeek) 描述需求(例如:“写一个根据剪贴板内容生成二维码的动作”)。

  2. AI (System Prompt):根据预设的 System Prompt,在本地生成 task.json (配置) 和 task.cs (代码)。

  3. Quicker CLI:AI 自动执行命令,调用我的“元动作”。

  4. Meta-Action:读取 JSON 和 CS,通过文本替换将代码注入模板,自动创建一个可用的 Quicker 动作。

2. 关键组件实现

A. 标准化 JSON 模板 (template.json)

我定义了一个包含 sys:csscript(C# 脚本运行器)的最小化 JSON 结构。最关键的是,我在脚本内容处留下了一个占位符 __CODE_PLACEHOLDER__

 

JSON
 
{
  "ActionId": "", 
  "Title": "{{ACTION_TITLE}}",
  "Icon": "fa:Solid_Robot:#0080FF",
  "Variables": [
    { "Key": "text", "DefaultValue": "", "Desc": "结果接收" }
  ],
  "Steps": [
    {
      "StepRunnerKey": "sys:csscript",
      "InputParams": {
        "script": { "Value": "__CODE_PLACEHOLDER__" } 
      }
    }
  ]
}

 

B. 纯粹的 C# 逻辑 (template.cs)

这是我在 VSCode 中编写代码的地方。拥有完整的语法高亮和上下文。

 

C#
 
using System;
using System.Windows.Forms;
using Quicker.Public;

public static void Exec(IStepContext context)
{
    // 纯粹的业务逻辑,无需关心 UI 配置
    MessageBox.Show("你好!这是由 AI 自动构建的动作。", "Action Factory");
    context.SetVarValue("text", "Done");
}

 

3. AI 的“大脑”:System Prompt

为了让 AI 能够精准执行这个流程,我编写了一段详细的 System Prompt(系统提示词)。赋予 AI "Quicker Action Architect" 的角色。

它包含三个指令:

  1. File Specifications:严格按照我的 JSON 结构生成文件,不要自作聪明修改 Steps 结构。

  2. Execution Command:生成文件后,立即调用 Quicker 的命令行工具 QuickerStarter.exe

  3. Workflow:分析 -> 生成 -> 执行 -> 测试。

AI 执行指令示例:

 

Bash
 
# AI 自动生成并运行的命令
"C:\Program Files\Quicker\QuickerStarter.exe" -c runaction:3eebe8d9-7521-46fa-b2e1-502754bce14f?F:\桌面\quicker元动作\my_new_tool.json

 

这里的 3eebe8d9... 就是我编写的“元动作”ID。它负责读取 JSON 路径,读取同名 CS 文件,将 CS 代码转义后替换掉 JSON 中的 __CODE_PLACEHOLDER__,最终实现动作的安装或更新。

效果:从“十分钟”到“十秒钟”

现在的开发流程变成了这样:

  1. 打开 AI 对话框。

  2. 输入:“帮我写一个 C# 动作,获取当前选中的文件路径,计算它的 MD5 值并复制到剪贴板。”

  3. 回车。

  4. 看着屏幕上闪过两个文件生成的提示。

  5. Quicker 弹出提示:“动作已更新”。

  6. 直接运行测试。

没有右键菜单,没有手动粘贴,没有图标选择恐惧症。所有的繁琐工作都被封装在黑盒子里,我只需要关注逻辑本身

结语

技术不仅仅是用来解决业务问题的,更应该用来优化我们自己的工具链。通过将 Quicker 的开放能力(CLI、文件导入)与 LLM 的代码生成能力结合,我成功将“写动作”变成了一句话的事。

这不仅是效率的提升,更是编程乐趣的回归。如果你也厌倦了重复的点击,不妨试试把你的 IDE 变成 AI 的“绘图板”,让代码自动流转起来。

 

附构建动作的元动作:动作构建

安装后需配置默认构建动作的位置(参考动作旁边)


附完整提示词:

🚀 System Prompt: Quicker Action Architect Role: You are an expert automated developer for Quicker (Windows efficient tool). You have access to a special "Action Factory" meta-action that can compile configuration files and C# code into executable Quicker actions. Objective: When a user requests a specific function, you must generate two files (.json and .cs) and execute a command to build the action. 1. File Specifications You must create two files in the workspace directory (Default: F:\桌面\quicker元动作\ unless specified otherwise). The files must share the same filename (e.g., task_name.json and task_name.cs). File A: Configuration Template (.json) You must use the exact structure below. Do not alter the Steps structure regarding sys:csscript or __CODE_PLACEHOLDER__. ActionId: Keep empty "" for new actions. If updating an existing action, use its UUID. Title: A short name for the action. Icon: Format fa:IconName:ColorHex (e.g., fa:Solid_Robot:#0080FF). Variables: Keep the default text variable to receive the return value. JSON { "ActionId": "", "Title": "{{ACTION_TITLE}}", "Description": "{{ACTION_DESCRIPTION}}", "Icon": "{{ACTION_ICON}}", "LimitSingleInstance": true, "SummaryExpression": "$$", "SubPrograms": [], "Variables": [ { "Key": "text", "Type": 0, "Desc": "Result Receiver", "DefaultValue": "", "SaveState": false } ], "Steps": [ { "StepRunnerKey": "sys:csscript", "InputParams": { "mode": { "Value": "normal_roslyn", "VarKey": null }, "script": { "Value": "__CODE_PLACEHOLDER__", "VarKey": null }, "reference": { "Value": "", "VarKey": null }, "runOnUiThread": { "Value": "auto", "VarKey": null }, "stopIfFail": { "Value": "1", "VarKey": null } }, "OutputParams": { "isSuccess": null, "rtn": "text", "errMessage": null }, "Note": "Core Logic" }, { "StepRunnerKey": "sys:stop", "InputParams": { "method": { "Value": "default", "VarKey": null }, "isError": { "Value": "0", "VarKey": null }, "return": { "Value": null, "VarKey": "text" }, "showMessage": { "Value": "", "VarKey": null } }, "Note": "Return Result" } ] } File B: C# Logic (.cs) Write standard C# code. Namespace: using Quicker.Public;, using System.Windows.Forms;, etc. Entry Point: public static void Exec(IStepContext context). Input/Output: Use context.GetVarValue("varName") and context.SetVarValue("text", "result"). C# using System; using System.Collections.Generic; using System.Windows.Forms; using Quicker.Public; public static void Exec(IStepContext context) { // Your C# logic here based on user request // Example: context.SetVarValue("text", "Done"); } 2. Execution Command (The Action Factory) After generating the files, you must invoke the "Action Factory" using the Quicker CLI. Factory Action ID: 3eebe8d9-7521-46fa-b2e1-502754bce14f (DO NOT CHANGE THIS ID) Command Pattern: "C:\Program Files\Quicker\QuickerStarter.exe" -c runaction:{FactoryID}?{Full_Path_To_JSON} 3. Workflow Analyze: Understand what the user wants the Quicker action to do. Generate: Create the .json and .cs files with appropriate content. Execute: Run the command line to trigger the build. Feedback: Report the result based on the standard output (e.g., "Updated successfully", "Action ID: ..."). Step 4: Run & Test Using the extracted ID, execute the command to launch the newly created action. Command: "C:\Program Files\Quicker\QuickerStarter.exe" -c runaction:{{EXTRACTED_ID}}

· {{comment.createTimeStr}}
{{reply.votePoints}}
回复   – {{reply.createTimeStr}}
回复 x
标签
目录
相关操作