Sending keystrokes to a DOS box from a Dialog Box.

Sending keystrokes to a DOS box from a Dialog Box.

Post by Sridhar Rajagopa » Tue, 29 Sep 1998 04:00:00



Hi,
I am trying to send a keystroke to a DOS command prompt from a Dialog Box
application in Win 95. I have found out that a DOS box receives a WM_USER +
26 when a key is pressed. (Did this using Spy++). Does anybody know what the
wParam and lParam are for this? I cannot seem to find this documented
anywhere.

Any help would be greatly appreciated.
Thanks,
-Sridhar.

 
 
 

Sending keystrokes to a DOS box from a Dialog Box.

Post by Ron Bur » Wed, 30 Sep 1998 04:00:00




Quote:> I am trying to send a keystroke to a DOS command prompt from a Dialog Box

Interesting trick: send a WM_DROPFILES to the console window, storing
the characters you want to deliver as the filename. From the Oct 98 Tech Tip
by D'Agostino:

void SendConsoleString(HWND hwnd, LPTSTR pCmdString)
{
    HGLOBAL     hDropFiles;
    LPDROPFILES pDropFiles;
    LPTSTR      pFileNames;
    DWORD       dwLength, dwBytes;

    //
    // Alloc mem for DROPFILES structure and initialize.  Filename
    // list has one entry that is double null-terminated.
    //
    dwLength = lstrlen(pCmdString);
    dwBytes = sizeof(DROPFILES) + (dwLength + 2) * sizeof(TCHAR);
    hDropFiles = GlobalAlloc(GHND, dwBytes);
    if (hDropFiles != NULL) {
        pDropFiles = GlobalLock(hDropFiles);
        if (pDropFiles != NULL) {
            pDropFiles->pFiles = sizeof(DROPFILES);
#ifdef UNICODE
            pDropFiles->fWide = TRUE;
#endif
            pFileNames = (LPTSTR)((char *)pDropFiles + \
                            sizeof(DROPFILES));
            lstrcpy(pFileNames, pCmdString);
            GlobalUnlock(hDropFiles);
            PostMessage(hwnd,WM_DROPFILES,(WPARAM) hDropFiles,0L);
        }
    }

Quote:}

 Ron Burk
 Windows Developer's Journal, www.wdj.com

 
 
 

1. Sending keystrokes to DOS boxes from a Dialog app.

Hi,
I am trying to send a keystroke to a DOS command prompt from a Dialog Box
application in Win 95. I have found out that a DOS box receives a WM_USER +
26 when a key is pressed. (Did this using Spy++). Does anybody know what the
wParam and lParam are for this? I cannot seem to find this documented
anywhere.

Any help would be greatly appreciated.
Thanks,
-Sridhar.

2. EXCESSIVE formatting of database results in fp2k

3. Send keystrokes to Dos box

4. DOS messages through NewDeal

5. Sending keystrokes to a DOS program running in an MSDOS Box

6. Glow filter w/Frontpage

7. Sending keystrokes to Win95 Dos-box

8. something nobody knows

9. Sending keystrokes to DOS boxes??

10. Sending Keystrokes to Dialog Boxes/Windows

11. Trapping Keystrokes in a Dialog Box or Dialog based application

12. Full screen DOS box freezes (Dos box scheduler problem?)

13. Dialog box from a Dialog Box