最小化除我自己的程序之外的所有其他应用程序 [英] Minimize all other applications excluding my own program

查看:50
本文介绍了最小化除我自己的程序之外的所有其他应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在运行我自己的程序时最小化 Windows 中所有正在运行的应用程序.我正在使用以下代码,但它最小化了我的程序包括的所有窗口.有什么方法可以最小化应用程序排除我的程序?

I am trying to minimize all running applications in Windows when running my own program. I am using the following code, but it's minimizing the all windows including my program. Is there any way that I can minimize the applications excluding my program?

我的代码如下:

try {
    Runtime.getRuntime().exec(
        new String[]{
            "cmd.exe",
            "/c",
            "\"" + System.getenv("APPDATA") +
            "\\Microsoft\\Internet Explorer\\Quick Launch\\Show Desktop.scf\""});
} catch (Exception ex) {
}

推荐答案

为什么不使用 JNA,它为您提供了许多使用 Windows 的选项...这就是您使用 JNA 的方式.下载JNA.jar

Why don't you use JNA, it gives you scores of options to play with windows... this is how you do it using JNA. download JNA.jar

HWND hwnd = User32.INSTANCE.FindWindow(null, nameOfWindow); // window title 
User32.INSTANCE.ShowWindow(hwnd, 9); // SW_RESTORE
User32.INSTANCE.SetForegroundWindow(hwnd); // bring to front

希望这会有所帮助...

Hope this helps...

这篇关于最小化除我自己的程序之外的所有其他应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆