Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 1998-09-10
1
Medium Priority
?
262 Views
Last Modified: 2013-11-20
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



0
Comment
Question by:mruff
1 Comment
 
LVL 7

Accepted Solution

by:
psdavis earned 100 total points
ID: 1322059
Have you tried passing the character directly to the window?

pDotpT->OnChar( nChar, nRepCnt, nFlags );

or

pDotpT->OnKeyDown( nChar, nRepCnt, nFlags );

Phillip
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month10 days, 2 hours left to enroll

927 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question