Spy++ didnt show the button.

denesh neupane 121 Reputation points
2022-03-02T06:20:25.247+00:00

i am trying to control an application from c# application . i used spy++ to navigate the button .but it doesnot work for all buttons. how to solve it?

private void button12_Click(object sender, EventArgs e)
      {
          IntPtr maindHwnd = FindWindow(null, "Inspector");
          if (maindHwnd != IntPtr.Zero)
          {
              //IntPtr panel = FindWindowEx(maindHwnd, IntPtr.Zero, "TPanel", null);
              IntPtr childHwnd = FindWindowEx(maindHwnd, IntPtr.Zero, " TPanel", "Connect");
              if (childHwnd != IntPtr.Zero)
              {
                  SendMessage(childHwnd, BM_CLICK, IntPtr.Zero, IntPtr.Zero);     // Send a message from the button
              }
              else
              {
                  textBox3.BackColor = Color.Yellow;
                  textBox3.Text = "エラー";
              }
          }
          else
          {
              textBox3.BackColor = Color.Yellow;
              textBox3.Text = "エラーメッセージボックスありません";
          }
      }
.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,647 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,648 questions
{count} votes

1 answer

Sort by: Most helpful
  1. RLWA32 43,306 Reputation points
    2022-03-02T11:22:31.253+00:00

    Spy++ (both 32-bit and 64-bit versions) will only show controls that are actual Win32 windows (i.e., have an HWND ). Some controls that appear on the screen may be windowless and so they are not displayed by Spy++. You can frequently see such controls by using the UIAutomation tool inspect.

    0 comments No comments