【问题标题】:Lua send command line to Windows (& Mac)Lua 向 Windows (& Mac) 发送命令行
【发布时间】:2020-04-08 15:30:07
【问题描述】:

我使用sendmidi 将midi 发送到Windows Midi 设备或在Mac 中发送到Mac Midi 设备。 在 Win 中,我可以从命令提示符发送,在终端中也可以: sendmidi.exe dev "Microsoft GS Wavetable Synth" pc 17 channel 1 on 60 90

我可以在不执行 .bat 或 .vbs 的情况下使用 Lua 发送命令行吗?

我可以使用

获取包含 Win 和 Mac 可执行文件 sendmidi.exe 和 sendmidi 的脚本路径
local info = debug.getinfo(1,'S');
script_path = info.source:match[[^@?(.*[\/])[^\/]-$]]

我还需要 CMD.exe 窗口静默运行或最小化。

所以我需要能够发送

"script_path..sendmidi.exe dev "Microsoft GS Wavetable Synth" pc 17 channel 1 on 60 90"

【问题讨论】:

    标签: cmd terminal lua send midi


    【解决方案1】:
    local script_path = debug.getinfo(1, 'S').source:match[[^@?(.*[\/])[^\/]*$]] or ""
    local command = '""'..script_path..'sendmidi.exe" dev "Microsoft GS Wavetable Synth" pc 17 channel 1 on 60 90"'
    os.execute(command)
    

    【讨论】:

      【解决方案2】:
      os.execute([command])
      

      请阅读 Lua 手册...

      https://www.lua.org/manual/5.3/manual.html#pdf-os.execute

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-04-27
        • 2012-03-15
        • 1970-01-01
        • 2010-11-14
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多