BUG: Num Lock Turned Off After Sending Keystrokes to DOS App.

ID: Q118818


The information in this article applies to:
  • Microsoft Visual Basic Standard and Professional Editions for Windows, versions 2.0, 3.0
  • Microsoft Visual Basic programming system for Windows, version 1.0


SYMPTOMS

After you activate an MS-DOS application in a window and send keystrokes to it, the Num Lock key, which had been turned on, is turned off.


WORKAROUND

You can use the KeyStat control to work around the problem. The following code fixes the example in the "MORE INFORMATION" section, below:


   ' Add a KeyStat control (KeyStat1 by default)
   ' Set the Style property to 1 - Num Lock
   ' Set the visible property to False
   Sub Command1_Click ()
      NumLockStatus = KeyStat1.Value
      Clipboard.SetText "DIR" + Chr(13)
      AppActivate "MS-DOS Prompt" ' Title of Windowed MS-DOS Session
      SendKeys "% ep"
      KeyStat1.Value = NumLockStatus
   End Sub 
NOTE: The KeyStat control does not fix the problem if you specify True for the Wait parameter in the SendKeys statement.


STATUS

Microsoft has confirmed this to be a bug in the Standard and Professional Editions of Visual Basic versions 2.0 and 3.0 for Windows and in the Visual Basic Programming System version 1.0 for Windows. We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.


MORE INFORMATION

Step-by-Step Example to Reproduce the Problem

  1. Start a new project in Visual Basic. Form1 is created by default.


  2. Add a command button to the form (Command1 by default), and place the following code in the click event:
    
          Sub Command1_Click ()
             Clipboard.SetText "DIR" + Chr(13)
             AppActivate "MS-DOS Prompt" ' Title of Windowed MS-DOS Session
             SendKeys "% ep"
          End Sub 


  3. Open an MS-DOS window. The MS-DOS window should be in the "Normal" state (use ALT + ENTER if necessary).


  4. If the title of the MS-DOS Window is not "MS-DOS Prompt", then modify the AppActivate statement in the command-button click event to read that way.


  5. Start the application.


  6. Turn Num Lock on.


  7. Press the command button. SendKeys sends the keystrokes "DIR" to the MS-DOS window. The Num Lock key gets turned off in the process.


Additional query words: buglist1.00 buglist2.00 buglist3.00 2.00 3.00 NumLock

Keywords :
Version :
Platform :
Issue type :


Last Reviewed: September 16, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.