lostfalling
2020-06-12 23:22
采纳率: 68.4%
浏览 569

再次试了下网上的代码FindWindowEx,根本找不到子窗口句柄,就试找登录按钮的句柄,高手来看看

[DllImport("user32.dll", EntryPoint = "FindWindow")]
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);

    [DllImport("user32.dll", EntryPoint = "FindWindowEx")]
    private static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

    [DllImport("user32.dll", EntryPoint = "SendMessage")]
    private static extern int SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam);
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        const int BM_CLICK = 0xF5;
        IntPtr maindHwnd = FindWindow("TXGuiFoundation", "QQ"); 
        if (maindHwnd != IntPtr.Zero)
        {
            IntPtr childHwnd = FindWindowEx(maindHwnd, IntPtr.Zero, null, "登录");  
            if (childHwnd != IntPtr.Zero)
            {
                SendMessage(childHwnd, BM_CLICK, 0, 0);    
            }
            else
            {
                MessageBox.Show("没有找到子窗口");
            }
        }
        else
        {
            MessageBox.Show("没有找到窗口");
        } 
    }
}
![图片说明](https://img-ask.csdn.net/upload/202006/12/1591975186_886143.png)

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • threenewbee 2020-06-13 09:00
    已采纳

    qq的话,它的按钮什么都是自己画的,本来就没有,你可以用spy++验证这一点。所以findwindow之类的api用不起来很正常。

    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题