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

Last reviewed: June 21, 1995
Article ID: Q118818
The information in this article applies to:
  • Standard and Professional Editions of Microsoft Visual Basic for Windows, versions 2.0 and 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 reference words: buglist1.00 buglist2.00 buglist3.00 1.00 2.00
3.00 NumLock
KBCategory: kbenv kbbuglist
KBSubCategory: EnvtRun


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: June 21, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.