实战教程:在 C# 动作中调用 Quicker 子程序

洛洛罗 2025/12/31 发布 · 2025/12/31 更新 · 20 次阅读

不需要看长篇大论,直接复制下面的代码,改 3 个地方就能用。

🚀 也就是这一段代码 (可以直接全选复制)

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Windows;
using Quicker.Public;

public static async Task Exec(IStepContext context)
{
    // [设置 1] 填入你要传给子程序的数据 (变量名 : 值)
    var inputs = new Dictionary<string, object> {
        { "input1", "你好" },
        { "input2", 100 }
    };

    try 
    {
        // [设置 2] "你的子程序名称" 改成实际的动作名
        var result = await context.RunSpAsync("你的子程序名称", inputs);

        // [设置 3] "resultKey" 改成子程序里输出变量的名字
        if (result != null && result.ContainsKey("resultKey")) 
        {
            var value = result["resultKey"].ToString();
            MessageBox.Show("成功获取到结果: " + value);
        }
    }
    catch (Exception ex) 
    {
        MessageBox.Show("调用失败: " + ex.Message);
    }
}

📝 只需要改这 3 个地方:

  1. input1 / input2: 子程序里定义的输入变量名
  2. "你的子程序名称": 你想调用的动作名字(或者 ID)。
  3. resultKey: 子程序里定义的输出变量名

直接安装修改即可:C#调用子程序Demo

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