Lua如何将命令行发送至Windows和Mac

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

我可以使用Lua发送命令行而不执行.bat或.vbs文件吗?

我可以获取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"
点赞
用户2858170
用户2858170
`os.execute([command])`

请阅读 Lua 手册...

[https://www.lua.org/manual/5.3/manual.html#pdf-os.execute](https://www.lua.org/manual/5.3/manual.html#pdf-os.execute)
2019-12-16 07:17:24
用户1847592
用户1847592
```lua
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)

``` 本地脚本路径=debug.getinfo( 1 , 'S').source :match [[^@?(.[/])[^/]$]])或 "" 命令='""'..script_path..'sendmidi.exe" dev "Microsoft GS Wavetable Synth" pc 17 channel 1 on 60 90"' os.execute(command)

2019-12-16 08:32:37