在lua中使用os.execute时如何避免弹出窗口 [英] how to avoid popup a window when use os.execute in lua
问题描述
我正在使用os.execute()
调用Lua中的其他程序,当程序运行时,cmd窗口会突然闪烁,并且我调用了execute超过100次,这变得很烦人.
那么有什么方法可以将窗口设置为不可见?
I am using os.execute()
to call other program in Lua, when program run,the cmd windows will popup for a blink, and I call the execute more than hundred times, and it become annoying.
So is there any way to set the window invisible?
推荐答案
简短的答案是hjpotter在评论中给出的: 不,你不能 .
The short answer was given by hjpotter in a comment: no, you can't.
随后将进行更详细的解释.
A longer explanation follows.
在Windows上,可执行文件具有两种形式": GUI应用程序和命令行应用程序.这与程序的内部工作无关,但取决于程序的构建方式(PE可执行标头中有一个标志,可以使用链接器选项设置该标志).当执行命令行应用程序时,操作系统会自动弹出控制台窗口(丑陋的黑匣子").
On Windows executable files come in "two flavors": GUI applications and command line applications. This has nothing to do with the inner workings of the program, but it depends on how the program was built (there is a flag for it in the PE executable header which can be set using a linker option). It is the OS that automatically pops up a console window (the "ugly black box") when a command line application is executed.
os.execute
的问题是它使用C system
功能,它可能又是通过执行Windows命令外壳可执行文件cmd.exe
来实现的,该可执行文件是命令行应用程序.因此,每次使用os.execute
时,实际上都在执行cmd.exe
.黑框是与cmd.exe
关联的控制台窗口.
The problem with os.execute
is that it uses C system
function under the hood, which in turn is probably implemented by executing the Windows command shell executable cmd.exe
, which is a command line application. Thus every time you use os.execute
you are indeed executing cmd.exe
. That black box is the console window associated with cmd.exe
being executed.
这篇关于在lua中使用os.execute时如何避免弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!