Sending keystrokes to Win95 Dos-box

Sending keystrokes to Win95 Dos-box

Post by Andy Kriechhamme » Fri, 29 Dec 2000 04:21:51



follow up to: comp.os.ms-windows.programmer.misc

How can I send keystrokes to a Console (DOS) application under Win95?

keybd_event() doesn't work in Win 95 for Dos-Boxes, although it works under
NT4.0.

I tried the following:

  // bring console window to foreground
  SetForegroundWindow(hGblForeGroundWindow))

  // Get app process and thread id
  intMyThreadID = GetWindowThreadProcessId(Application->Handle,
&intMyProcessID) ;

  // Get console process and thread id
  intToThreadID = GetWindowThreadProcessId(hGblForeGroundWindow,
&intToProcessID) ;

  // Attach console window thread to app
  AttachThreadInput(intToThreadID, intMyThreadID, TRUE))

  SendMessage(hGblForeGroundWindow, WM_CHAR, Key, lParam)

instead of calling SendMessage() I tried it with keybd_event() called two
times, first for keydown, than for keyup.
It only worked under NT4.0, not under Win95 :-(

SendInput() may work under 98, but I need a solution for 95. The good old
recorder.exe, digged out from Win 3.11 is able to send a recorded macro
containing keystrokes to a Dos-Box, therefore I suppose, this must be able
using just the 16-Bit API.

Any suggestions will be appreciated

TIA

Andy

--
Andy Kriechhammer
http://members.aon.at/kri
OE3ARC KLE500

 
 
 

Sending keystrokes to Win95 Dos-box

Post by Axel K?ste » Fri, 29 Dec 2000 19:04:15



Quote:> How can I send keystrokes to a Console (DOS) application under Win95?
> keybd_event() doesn't work in Win 95 for Dos-Boxes, although it works
under
> NT4.0.

Hello Andy Kriechhammer,

You could write a VXD and use VKD_Force_Keys to send scan codes
into the keyboard buffer.

Regards
Axel

 
 
 

Sending keystrokes to Win95 Dos-box

Post by Andy Kriechhamme » Sat, 30 Dec 2000 03:34:26


Quote:> How are you calling keybd_event()? Did you try passing the
> the bScan (hardware scan code) parameter?

No! I set the scan code to 0, since this worked under NT4.0.
And after I passed the result of MapVirtualKey() as an arg, it worked under
95 as well!!!!

Thanks a lot for your help

Andy

 
 
 

Sending keystrokes to Win95 Dos-box

Post by Andy Kriechhamme » Mon, 01 Jan 2001 00:41:11


And the next problem came up quite quickly:
Calling VkKeyScan() with german keyboardlayout for the backslash ('\\')
gives me the virtual keycode and tells me, that the Ctrl and Alt keys has to
be pressed to generate this key. But the Dos-Box ignores Ctrl-Alt-\ if I
send this keys with keybd_event() and if I press this keys on the keyboard
directly. The backslash is generated in a Dos-Box only if I press the Alt-Gr
+ the backslash key.
Win NT (I love this OS!) behaves correct and creates a backslash.
I should go and ask in a german Win95 newsgroup but if anyone has an idea,
I'll appreciate this.

TIA

Andy

 
 
 

1. Sending keystrokes to a DOS box from a Dialog Box.

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. pointless question

3. Send keystrokes to Dos box

4. Context Manager loses context

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

6. Getting return value from exe file at command prompt.

7. Sending keystrokes to DOS boxes??

8. Tile Ripper

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

10. Send Message from DOS-Box to Win-Prog

11. WIN95 (WIN32 C++): Q: Subclassing a 16 bit Dos-box???

12. Sending Keystrokes to DOS from VISUAL BASIC

13. Sending keystrokes from VB to DOS app