private void button2_Click(object sender, EventArgs e) { Process[] ProceddingCon = Process.GetProcesses(); //获得所有进程 IntPtr intPtr = IntPtr.Zero; foreach (Process IsProcedding in ProceddingCon) { var str = Process.GetCurrentProcess().ProcessName; //osk.exe if (IsProcedding.ProcessName == "osk") //获得当前进程名称 { intPtr = IsProcedding.Handle; } } //通过句柄设置当前窗体最大化(0:隐藏窗体,1:默认窗体,2:最小化窗体,3:最大化窗体,....) bool result = ShowWindowAsync(intPtr, 0); //无效 // 获取查找窗体句柄(通过窗体标题名) IntPtr mainHandle = FindWindow(null, "屏幕键盘"); bool result1 = ShowWindowAsync(mainHandle, 0); //有用 MessageBox.Show("0000"); }