2

I am trying to get All Children window handles of third party application which is running in Background Processes Section of Task manager. I have tried with Main Window Handle but as application is running as Background Processes it is resulting Main Window handle as zero. Can anyone help me in resolving my issue ?

Process[] process = Process.GetProcessesByName("ipmsg");
        foreach (Process theprocess in process)
        {
            MessageBox.Show(theprocess.ProcessName);
        }
        IntPtr handle = process[0].MainWindowHandle;
        Process[] process1 = Process.GetProcessesByName("ipmsg");
        process1[0].WaitForInputIdle();
        IntPtr pt = process1[0].MainWindowHandle;
        MessageBox.Show(pt.ToString());
        string title = process[0].MainWindowTitle;

        StringBuilder className = new StringBuilder(200);
        int nret = GetClassName(handle, className, className.Capacity);
        IntPtr appHandle = handle;
        string caption1 = GetTextBoxText(appHandle);
        richTextBox1.AppendText(caption1 + " " + System.Environment.NewLine);
        richTextBox1.AppendText("App handle = " + appHandle.ToString("X"));
        List<string> children = GetAllChildrenWindowHandles(appHandle, 100);
        richTextBox1.AppendText("Children handles are:" + System.Environment.NewLine);
        for (int i = 0; i < children.Count; ++i)
        {
            Console.WriteLine(Convert.ToInt32(children[i]).ToString("X"));
            richTextBox1.AppendText(Convert.ToInt32(children[i]).ToString("X") + " " + System.Environment.NewLine);
            IntPtr appHandle_sub = new IntPtr(Convert.ToInt32(Convert.ToInt32(children[i]).ToString("X"), 16));
            string caption = GetTextBoxText(appHandle_sub);
            richTextBox1.AppendText(caption + " " + System.Environment.NewLine);
        }
John Wick
  • 169
  • 1
  • 13

0 Answers0