最近网络很不稳定,学校联网非得用锐捷,总是掉线,想写个工具检测掉线自动重连. while(1)
{
HWND hwnd = NULL;
hwnd=::FindWindow("#32770","锐捷认证客户端");
if(::IsWindowVisible(hwnd))
{
::SetWindowPos(hwnd ,HWND_TOPMOST,NULL,NULL,NULL,NULL,SWP_NOSIZE | SWP_NOMOVE );
CWnd * pWnd = CWnd::FromHandle(hwnd);
CString str="";
pWnd->GetWindowText(str);
pWnd->SetWindowText("111111");    //无法操作窗口
pWnd->Invalidate(TRUE);
::PostMessage(hwnd, WM_KEYDOWN, VK_RETURN , 1); 
::PostMessage(hwnd,WM_KEYUP, VK_RETURN, 1);    
}
}
目前可以获得锐捷认证窗口的句柄以及上面所有控件的句柄.但现在不能操作这个窗口,例如修改标题啊等等.
对其他窗口操作是可以的.例如换成飞信的窗口,上面的代码就可以通过输入回车发送消息了,也可以正常修改标题.这是什么原因呢?应该如何解决呢?

解决方案 »

  1.   

    如果加密了,为什么GetWindowText可以,但Set不行呢..
      

  2.   

    我改成了模拟鼠标操作了.为什么写出来的代码在xp下好使,模拟鼠标有反应,但在win 7下就不行呢...
      

  3.   

    模拟鼠标点击mouse_event/SendInput()就可以了
      

  4.   


    已经改成了mouse_event了,在xp下已经可以自动重连了
    在win7下还是不行....
      

  5.   

    我也遇到类似的问题,keybd_event不好使,后来发送WM_KEYDOWN和WM_KEYUP消息解决了
      

  6.   

    The SetWindowText function changes the text of the specified window's title bar (if it has one). If the specified window is a control, the text of the control is changed. However, SetWindowText cannot change the text of a control in another application.
    To set the text of a control in another process, send the WM_SETTEXT message directly instead of calling SetWindowText
      

  7.   

    User Interface Privilege Level Isolation