隐藏由java应用程序启动的窗口应用程序?
我正在开发一个 Java 应用程序,它必须启动另一个应用程序。如果我使用 Runtime.getRuntime().exec() 启动第二个应用程序,它将成为活动进程,并且其窗口位于我的应用程序窗口之前。我真正想做的是在“隐藏”模式下启动该进程,以便其任务栏条目不会出现,并且其窗口最初不可见或位于我的应用程序窗口后面。然后我的应用程序将使其可见或在其准备就绪时将其移动到前面。这是可能的还是我要求太多?
这是一个演示。所以我不担心安全问题。
编辑:丹尼尔的回答给了我一个想法。如果我使用 Powershell 而不是 CMD.EXE 来调用应用程序会怎样?这会让我在没有窗口的情况下启动应用程序,然后恢复窗口吗?我将使用启动 java 来启动 PowerShell 来启动应用程序,但到底是什么!
I am working on a Java application which has to launch a different application. If I launch the second application using Runtime.getRuntime().exec()
, it becomes the active process and its window comes before my application's window. What I really want to do is launch the process in "hidden" mode so that its taskbar entry does not appear and its window is initially invisible or behind my application window. Then my application would make it visible or move it to the front when it is good and ready. Is this possible or am I asking for too much?
This is for a demo. So I am not worried about security issues.
Edit: Daniel's answer has given me an idea. What if I use Powershell to invoke the application instead of CMD.EXE? Will that let me start the app without the window and then bring the window back? I will be using to launch java to launch PowerShell to launch app, but what the heck!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您没有说这个其他应用程序是什么,但我假设它是您无法控制的应用程序(即您不能给它一个参数选项以最小化模式或类似模式启动。)而不是隐藏您正在启动的应用程序,您可以在另一个应用程序启动后在您的窗口上使用 toFront() 方法将您的窗口置于另一个应用程序的前面吗?然后当您想显示另一个窗口时最小化您的窗口?
我是第一个承认这是一个有点犹豫的解决方案的人,但它可能会起作用,具体取决于你想要什么。
You don't say what this other application is, but I'm assuming that it's one that you have no control over (i.e. you can't give it a parameter option to start up in a minimized mode or similar.) Rather than hide the application you're launching, can you just use the toFront() method on your window after the other application has launched to bring your window in front of the other? And then minimize your window when you want to reveal the other one?
I'm the first to admit it's a bit of a bodged solution, but it might work depending on what you're after.
您无法提供这些参数,但您可以使用支持这些参数的“start”命令(在cmd中尝试)。最终你必须使用 cmd.exe shell 来调用它,但这会起作用!
You cannot provide these parameters, BUT you can use the "start" command (try it in cmd), which supports these parameters. Eventually you have to call it with a cmd.exe shell, but this will work!