简体   繁体   English

真正最小化另一个应用程序

[英]True minimizing for another application

I just want to do real minimized, all public codes are not minimizing in right way! 我只想做最小化,所有公共代码都没有以正确的方式最小化! It just minimize it as shown, but not minimize like if I click on Minimize button. 它只是将其最小化,如图所示,但没有像我单击“最小化”按钮那样将其最小化。 How did I know that? 我怎么知道的 Or what benefit will I get from that? 或我将从中得到什么好处? When I press on minimize button, it reduce from CPU usage! 当我按下最小化按钮时,它将减少CPU使用率! (It's a game anyway.) (还是游戏。)

My code is : 我的代码是:

    [DllImport("User32.Dll", EntryPoint = "PostMessageA", SetLastError = true)]
    public static extern bool PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam);

    List<int> ProcIDs = new List<int>();
    private void timer1_Tick(object sender, EventArgs e)
    {
        foreach (Process process in Process.GetProcesses())
        {
            if (process.ProcessName == "League of Legends")
            {
               // MinimizeWindow((IntPtr)hProcess);
                if (!ProcIDs.Contains(process.Id))
                {
                    IntPtr hProcess = GetProcessWindow(process.Id);
                    ProcIDs.Add(process.Id);
                    PostMessage(hProcess, WM_SYSCOMMAND, (IntPtr)SC_MINIMIZE, IntPtr.Zero);
                }
            }
        }
}
    const int WM_SYSCOMMAND = 274;
    const int SC_MINIMIZE = 0xF020;

I also tried other methods and it does the same, just minimize as show, but not real minimize! 我还尝试了其他方法,它的作用相同,只是最小化显示,而不是真正的最小化! :) :)

You can try this 你可以试试这个

[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, WindowShowStyle nCmdShow);

with window style as ShowMinimized = 2, 窗口样式为ShowMinimized = 2,

http://www.pinvoke.net/default.aspx/user32.showwindow http://www.pinvoke.net/default.aspx/user32.showwindow

暂无
暂无

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

相关问题 最小化后应用程序变慢 - Application becomes sluggish after minimizing 使用WPF最小化/关闭应用程序到系统托盘 - Minimizing/Closing Application to system tray using WPF 在显示另一个表单的同时最小化和还原一个表单 - Minimizing and restoring a form while showing another form 从任务栏最小化后,Application.OpenForms为空 - Application.OpenForms empty after minimizing from taskbar 最小化表单应用程序 c# 时任务栏图标消失 - Taskbar icon disappears when minimizing form application c# 最小化应用程序表单会导致模式窗体关闭,但不会关闭MessageBox - Minimizing the application form causes a modal form to close, but not a MessageBox 使用WPF将应用程序最小化到系统托盘(不使用NotifyIcon) - Minimizing Application to system tray using WPF ( Not using NotifyIcon ) 当另一个应用程序在我的应用程序顶部打开时,如何使用 TopMost=true 关闭 winform - How to close winform with TopMost=true, when another application opens on top of my app 在单击事件后加载时,功能区应用程序菜单(下拉菜单)未在 WPF 应用程序中最小化(关闭或失去焦点) - Ribbon application menu (dropdown) is not minimizing (closing or losing focus) in WPF application while loading after a click event 语音到文本的转换:帮助通过转换后的文本打开文件以及最小化和最大化应用程序 - Voice to text conversion : Help on opening a file through converted text and minimizing and maximizing an application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM