Link to home
Start Free TrialLog in
Avatar of mruff
mruff

asked on

Sending a keystroke to the active window as if typed at the keyboard.

I want to send a keystroke to another app. (16.bit, old)
i've tried:
      CWnd* pDoptT;
      pDoptT      =  GetNextWindow(GW_HWNDNEXT);
      do
      {
        CString strWindowTitle;
          pDoptT->GetWindowText(strWindowTitle);
        if(strWindowTitle.Find("App to receive key") !=-1)
          {
            //found the app i want to send keystrokes
          ::SetForegroundWindow(pDoptT->m_hWnd);
            ::SendMessage(pDoptT->m_hWnd,WM_KEYDOWN, (WPARAM) iVirtKeyCode, (LPARAM) 0);
                  
            }
            pDoptT      = DoptT->GetNextWindow(GW_HWNDNEXT);
      }while(pDoptT != NULL);

somehow the other app does not react, any other solutions?

                       thanx martin



ASKER CERTIFIED SOLUTION
Avatar of psdavis
psdavis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial