Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //https://stackoverflow.com/questions/29327301/how-to-detect-is-a-window-of-another-process-minimized-or-maximized/29327657
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Diagnostics;
- using System.Drawing;
- using System.Linq;
- using System.Runtime.InteropServices;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- namespace DetectMinimizedWindow
- {
- public partial class Form1 : Form
- {
- [DllImport("user32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- static extern bool IsIconic(IntPtr hWnd);
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- Process process = Process.GetProcesses()
- .Where(p => p.MainWindowTitle == "Untitled - Notepad").SingleOrDefault();
- if (process != null)
- {
- IntPtr wHnd = process.MainWindowHandle;
- Console.WriteLine("Minimized: " + IsIconic(wHnd));
- MessageBox.Show("Minimized: " + IsIconic(wHnd));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment