我也不知道是否应该在此处发帖.
我在autohotkey代码中调用cmd命令, 最终不得不用ComObj实现, 但我没学过, 拼凑的, 不过最终还是dos命令.- RunWaitMany(abc)
- RunWaitMany(commands) {
- shell := ComObjCreate("WScript.Shell")
- ; Open cmd.exe with echoing of commands disabled
- exec := shell.Exec(ComSpec " /K echo on")
- ; Send the commands to execute, separated by newline
- exec.StdIn.WriteLine(commands "`nexit") ; Always exit at the end!
- ; Read and return the output of all commands
- return exec.StdOut.ReadAll()
- }
复制代码 abc是个3行文本, 代表3个命令
本来运行的时候隐藏cmd窗口的, 我把exec := shell.Exec(ComSpec " /Q /K echo off") 改成了 exec := shell.Exec(ComSpec " /K echo on"), cmd窗口出现了, 带标题, 但内容始终是空, 而实际上运行正常
高手教我 |