简体   繁体   中英

Send TAB key Event using PostMessage, mfc

I have code which PostMessage() which pastes the Text from Clipboard text to Notepad. Now in another application their are two Edit box, in this case i want to Paste the text then Enter TAB Key Press event (ie Using PostMessage() send TAB key event)will take , so that me to next edit control and then again I will sent the PostMessage() to paste the text from clipboard.I am able to do it for One text box. how can i do it with two or say three edit box. Here is what i have tried.

//CWnd *pWnd=FindWindow(NULL,_T("Untitled - Notepad"));
    CWnd *pWnd=FindWindow(NULL,_T("Visual SourceSafe Login"));
    HWND mainHwnd = pWnd->GetSafeHwnd();
    CString csNameOfWin;
    pWnd->GetWindowTextA(csNameOfWin);

    CWnd *EditHwnd = FindWindowEx(mainHwnd,NULL,"edit",NULL);
    EditHwnd->PostMessageA(WM_PASTE,0,0);
    EditHwnd->PostMessageA(VK_TAB,0,0);
    EditHwnd->PostMessageA(WM_PASTE,0,0);

But this doesn't work for me can someone please tell me what is the problem with the code. Please guide me through the right path. Thanks in Advance.

You don't want WM_KEYDOWN / VK_TAB . You are looking for WM_NEXTDLGCTL .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM