我想写个程序。通过api中的PostMessage方法向其他的win程序的输入框中写入东西。不知道如何实现
有些帖子是说用GetDlgltem。这个东西在哪里呢?怎么引入到C#项目中使用?

解决方案 »

  1.   

    [DllImport("user32.dll", EntryPoint = "FindWindow")]
    private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
    [DllImport("user32.dll")]
    static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);private void button1_Click(object sender, EventArgs e)
    {
      IntPtr hWnd1 = FindWindow(null, "主窗口标题");   
      SetForegroundWindow(hWnd1);
      IntPtr hWnd2 = FindWindowEx(hWnd1, IntPtr.Zero, null, "控件文本");   
      IntPtr hWnd3 = FindWindowEx(hWnd1, IntPtr.Zero, "控件类名", null);   
    }
      

  2.   

    没有找到。。这个输入框不是win窗体的直接子窗口。上边可能是有panel之类的控件。在这些容器中呢。。