简体   繁体   English

隐藏由Java应用程序启动的窗口化应用程序?

[英]Hiding a windowed application launched by a java application?

I am working on a Java application which has to launch a different application. 我正在研究必须启动其他应用程序的Java应用程序。 If I launch the second application using Runtime.getRuntime().exec() , it becomes the active process and its window comes before my application's window. 如果我使用Runtime.getRuntime().exec()启动第二个应用程序,则它将成为活动进程,并且其窗口位于应用程序窗口之前。 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? 如果我使用Powershell而不是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! 我将使用启动Java来启动PowerShell来启动应用程序,但是该死!

You don't say what this other application is, but I'm assuming that it's one that you have no control over (ie 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? 您没有说这个其他应用程序是什么,但是我假设它是您无法控制的(即,您不能给它一个参数选项以最小化模式或类似模式启动)。您正在启动的应用程序,是否可以在另一个应用程序启动后将窗口置于另一个窗口之前,仅在窗口上使用toFront()方法? 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. 我是第一个承认这是一个固定的解决方案的人,但它可能会根据您的需求而起作用。

You cannot provide these parameters, BUT you can use the "start" command (try it in cmd), which supports these parameters. 您不能提供这些参数,但是可以使用支持这些参数的“启动”命令(在cmd中尝试)。 Eventually you have to call it with a cmd.exe shell, but this will work! 最终,您必须使用cmd.exe Shell调用它,但这将起作用!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM