获取窗体句柄
我想自动点击qq登陆按钮,怎么获取那个登陆窗体句柄呢,用spy++查看,不会用,郁闷关键是代码。。呵呵,怎么实现这个操作...
我想自动点击qq登陆按钮,怎么获取那个登陆窗体句柄呢,用spy++查看,不会用,郁闷
关键是代码。。呵呵,怎么实现这个操作 展开
关键是代码。。呵呵,怎么实现这个操作 展开
2个回答
展开全部
//获取QQ登陆窗口句柄
CWnd *pWnd = FindWindow(_T("#32770"), _T("QQ用户登录"));
if(!pWnd)
{
MessageBox("未发现窗口");
}
else
{
//点击登陆按钮
CButton *pbtnLogin = (CButton *)pWnd->GetDlgItem(16032);
if (pbtnLogin)
{
pbtnLogin->PostMessage(WM_LBUTTONDOWN, 0, 0);
pbtnLogin->PostMessage(WM_LBUTTONUP, 0, 0);
}
}
或者:
//获取QQ登陆窗口句柄
HWND hWnd = ::FindWindow(_T("#32770"), _T("QQ用户登录"));
if(!hWnd)
{
MessageBox("未发现窗口");
}
else
{
//点击登陆按钮
HWND hbtnLogin = ::GetDlgItem(hWnd, 16032);
if (hbtnLogin)
{
::PostMessage(hbtnLogin, WM_LBUTTONDOWN, 0, 0);
::PostMessage(hbtnLogin, WM_LBUTTONUP, 0, 0);
}
}
CWnd *pWnd = FindWindow(_T("#32770"), _T("QQ用户登录"));
if(!pWnd)
{
MessageBox("未发现窗口");
}
else
{
//点击登陆按钮
CButton *pbtnLogin = (CButton *)pWnd->GetDlgItem(16032);
if (pbtnLogin)
{
pbtnLogin->PostMessage(WM_LBUTTONDOWN, 0, 0);
pbtnLogin->PostMessage(WM_LBUTTONUP, 0, 0);
}
}
或者:
//获取QQ登陆窗口句柄
HWND hWnd = ::FindWindow(_T("#32770"), _T("QQ用户登录"));
if(!hWnd)
{
MessageBox("未发现窗口");
}
else
{
//点击登陆按钮
HWND hbtnLogin = ::GetDlgItem(hWnd, 16032);
if (hbtnLogin)
{
::PostMessage(hbtnLogin, WM_LBUTTONDOWN, 0, 0);
::PostMessage(hbtnLogin, WM_LBUTTONUP, 0, 0);
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询