FIX: SendKeys Function Locks Keyboard on Windows 2000 (276346)
The information in this article applies to:
- Microsoft Visual Basic Professional Edition for Windows 5.0, when used with:
- the operating system: Microsoft Windows 2000 SP1
- Microsoft Visual Basic Professional Edition for Windows 6.0, when used with:
- the operating system: Microsoft Windows 2000 SP1
- Microsoft Visual Basic Enterprise Edition for Windows 5.0, when used with:
- the operating system: Microsoft Windows 2000 SP1
- Microsoft Visual Basic Enterprise Edition for Windows 6.0, when used with:
- the operating system: Microsoft Windows 2000 SP1
This article was previously published under Q276346 SYMPTOMS
When a Visual Basic program is running, the keyboard on your Windows 2000-based computer freezes.
This problem can also occur if the application is hosted on a Terminal Server, and if the client is running Windows 2000. The following system event is logged on the Windows 2000-based computer:
Event Type:Error
Event Source:i8042prt
Event Category:None
Event ID:27
Description:
The operation on timed out (time out is configurable via the registry).
CAUSE
This problem is the result of a bug in the Windows 2000 keyboard driver, and only occurs in conjunction with the Visual Basic SendKeys function.
RESOLUTION
To resolve this problem on a Windows 2000-based computer that is not running Terminal Services, install Windows 2000 Service Pack 2 (SP2) from the following Microsoft Web site:
A supported hotfix is now available from Microsoft, but it is only intended to correct the problem that is described in this article. Only apply it to systems that are experiencing this specific problem. This hotfix may receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next Windows 2000 service pack that contains this hotfix. To resolve this problem immediately, contact Microsoft Product Support Services to obtain the fix. For a complete list of Microsoft Product Support Services phone numbers and information about support costs, visit the following Microsoft Web site: NOTE: In special cases, charges that are ordinarily incurred for support calls may be canceled if a Microsoft Support Professional determines that a specific update will resolve your problem. The typical support costs will apply to additional support questions and issues that do not qualify for the specific update in question.
The English version of this fix should have the following file attributes or later:
Date Time Version Size File name
-----------------------------------------------------------
05/18/2000 07:17p 5.0.2195.2096 48,592 I8042prt.sys
To unlock the keyboard manually, on the Start menu, point to Settings, and then click Control Panel. Click Keyboard, and then reset the Keyboard Refresh Rate.
WORKAROUND
There are also two programmatic workarounds to this problem:
Workaround 1
Replace the SendKeys function with the keybd_event API function as follows:
Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte,ByVal _
bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Const KEYEVENTF_KEYUP = &H2
Const VK_TAB = &H9
keybd_event VK_TAB, 0, 0, 0
keybd_event VK_TAB, 0, KEYEVENTF_KEYUP, 0
Workaround 2
Replace the Sendkeys function with the PostMessage API function as follows:
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" _
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
Const WM_KEYDOWN As Long = &H100
Const VK_TAB As Long = &H9
Dim retVal as long
retVal = PostMessage(Me.hwnd, WM_KEYDOWN, VK_TAB, 0)
STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.
Modification Type: | Minor | Last Reviewed: | 9/12/2006 |
---|
Keywords: | kbHotfixServer kbQFE kbBug kbpending kbprb kbQFE KB276346 |
---|
|