Ejemplo n.º 1
0
 public void UpdateWindowsList(IntPtr[] all)
 {
     listBox1.Items.Clear();
     foreach (IntPtr hwnd in all)
     {
         string s = PInvokeFunc.GetWindowText(hwnd);
         listBox1.Items.Add(new AppRecord(s, hwnd));
     }
 }
Ejemplo n.º 2
0
        private static IntPtr[] GetPossibleWindows()
        {
            List <IntPtr> result = new List <IntPtr>();

            IntPtr[] all = PInvokeFunc.GetDesktopWindowHandles(IntPtr.Zero);
            uint     pid = 0;

            try
            {
                if (agth.CurrentApp != null)
                {
                    Process p = GetProcessByFullName(agth.CurrentApp);
                    if (p != null)
                    {
                        pid = (uint)p.Id;
                    }
                }
            }
            catch (Exception)
            {
            }
            foreach (IntPtr hwnd in all)
            {
                if (hwnd == Form1.thisForm.Handle)
                {
                    continue;
                }
                if (pid != 0)
                {
                    uint curPid;
                    PInvokeFunc.GetWindowThreadProcessId(hwnd, out curPid);
                    if (pid != curPid)
                    {
                        continue;
                    }
                }
                string s = PInvokeFunc.GetWindowText(hwnd);
                if (s == null || s == "")
                {
                    continue;
                }
                Rectangle rect = PInvokeFunc.GetWindowRect(hwnd);
                if (rect.Width >= 640 && rect.Width < 1300)
                {
                    result.Add(hwnd);
                }
            }
            return(result.ToArray());
        }