Microsoft KB Archive/118818

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

Article ID: 118818

Article Last Modified on 12/9/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Standard Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Visual Basic 3.0 Professional Edition
 * Microsoft Visual Basic 1.0 Standard Edition

-



This article was previously published under Q118818



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.



Step-by-Step Example to Reproduce the Problem
 Start a new project in Visual Basic. Form1 is created by default.  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  Open an MS-DOS window. The MS-DOS window should be in the "Normal" state (use ALT + ENTER if necessary). 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. Start the application. Turn Num Lock on.</li> Press the command button. SendKeys sends the keystrokes "DIR" to the MS-DOS window. The Num Lock key gets turned off in the process.</li></ol>

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

Keywords: kbbug KB118818

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.