[英]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.