Re: keybd_event,clipboard problem
 
I would use SendInput.
   INPUT Inputs[4];
   memset(Inputs,0,sizeof(INPUT)*4);
   Inputs[0].type = INPUT_KEYBOARD;
   Inputs[0].ki.wVk = VK_CONTROL;
   Inputs[1].type = INPUT_KEYBOARD;
   Inputs[1].ki.wVk = 'C';
   Inputs[2] = Inputs[1];
   Inputs[2].ki.dwFlags = KEYEVENTF_KEYUP;
   Inputs[3] = Inputs[0];
   Inputs[3].ki.dwFlags = KEYEVENTF_KEYUP;
   UINT Ret = SendInput(4,Inputs,sizeof(INPUT));
I tested this myself and it work.
void CSendInputDlg::OnBnClickedSelectTarget()
{
   m_SelectWindow = TRUE;
   SetCapture();
}
void CSendInputDlg::OnLButtonDown(UINT nFlags, CPoint point)
{
   if (m_SelectWindow)
   {
      m_SelectWindow = FALSE;
      GetCursorPos(&m_Point);
      CWnd *pWnd = WindowFromPoint(m_Point);
      if (pWnd)
      {
        CString Temp;
         pWnd->GetWindowText(Temp);
         m_Title.SetWindowText(Temp);
      }
      else
      {
         m_Title.SetWindowText("None");
      }
   }
   CDialog::OnLButtonDown(nFlags, point);
}
void CSendInputDlg::OnBnClickedCopy()
{
   SetTimer(100,100,NULL);
}
void CSendInputDlg::OnTimer(UINT nIDEvent)
{
   KillTimer(100);
   FocusTheTarget();
   INPUT Inputs[4];
   memset(Inputs,0,sizeof(INPUT)*4);
   Inputs[0].type = INPUT_KEYBOARD;
   Inputs[0].ki.wVk = VK_CONTROL;
   Inputs[1].type = INPUT_KEYBOARD;
   Inputs[1].ki.wVk = 'C';
   Inputs[2] = Inputs[1];
   Inputs[2].ki.dwFlags = KEYEVENTF_KEYUP;
   Inputs[3] = Inputs[0];
   Inputs[3].ki.dwFlags = KEYEVENTF_KEYUP;
   UINT Ret = SendInput(4,Inputs,sizeof(INPUT));
   CDialog::OnTimer(nIDEvent);
}
void CSendInputDlg::FocusTheTarget()
{
   SetCursorPos(m_Point.x,m_Point.y);
   INPUT Inputs[2];
   Inputs[0].type = INPUT_MOUSE;
   Inputs[0].mi.dx = 0;
   Inputs[0].mi.dy = 0;
   Inputs[0].mi.mouseData = 0;
   Inputs[0].mi.dwFlags = MOUSEEVENTF_LEFTDOWN;
   Inputs[0].mi.time = 0;
   Inputs[0].mi.dwExtraInfo = 0;
   Inputs[1] = Inputs[0];
   Inputs[1].mi.dwFlags = MOUSEEVENTF_LEFTUP;
   UINT Ret = SendInput(2,Inputs,sizeof(INPUT));
   Sleep(100);
}
"lencastro" <lencastro@gmail.com> wrote in message
news:1174917925.563646.237330@y66g2000hsf.googlegroups.com...
This is what i'm doing....
::keybd_event(VK_CONTROL,0,0 , 0);
::keybd_event('C',0,0, 0);
::keybd_event('C',0,KEYEVENTF_KEYUP,0);
::keybd_event(VK_CONTROL,0,KEYEVENTF_KEYUP,0);
if (::OpenClipboard(NULL))
   {
       HANDLE hclipbrd = ::GetClipboardData(CF_HDROP);
    if (NULL != hclipbrd)
       {
           UINT uFiles = ::DragQueryFile((HDROP) hclipbrd,
0xffffffff, NULL,0);
           char szFilename[MAX_PATH];
           for (UINT uIndex = 0; uIndex < uFiles; uIndex++)
           {
               ::DragQueryFile((HDROP) hclipbrd, uIndex,
szFilename,sizeof(szFilename));
           }
       }
       ::CloseClipboard();
}