PRB: Windows 95 Ignores ALT+TAB from SendKeys in Visual Basic

Last reviewed: October 30, 1995
Article ID: Q129839
The information in this article applies to:
  • Standard, Professional, and Enterprise Editions of Microsoft Visual Basic, 16-bit and 32-bit, for Windows, version 4.0
  • 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

A Visual Basic application running under Windows 95 is unable to use SendKeys to send an ALT+TAB key sequence to the operating system. The application can use SendKeys to send an ALT+TAB key sequence to the operating system when the application is running under Windows version 3.x, Windows for Workgroups, or Windows NT.

Windows 95 ignores the ALT+TAB key sequence sent by the Visual Basic application.

CAUSE

Windows 95 handles the processing of the ALT+TAB key sequence differently. When you press the ALT+TAB key sequence, Windows 95 handles it immediately rather than placing it in the message queue as Windows 3.x, Windows for Workgroups, and Windows NT do. Therefore, placing the ALT+TAB sequence in the message queue by using SendKeys does not produce the desired behavior.

RESOLUTION

Modify any application that programmatically sends an ALT+TAB key sequence to the Windows 95 operating system.

NOTE: Using the ALT+TAB keystroke sequence to make an application active is not recommended by Microsoft under any operating system. In Visual Basic, use the AppActivate statement instead.

STATUS

This behavior is by design. It is not a problem with Visual Basic. It is a difference in the behavior of Windows 95. By design, Windows 95 handles the ALT+TAB keystroke sequence differently.

MORE INFORMATION

Steps to Reproduce the Behavior

  1. Start Visual Basic.

  2. From the File menu, choose New Project.

  3. Enter the following code into the Form's Click event procedure:

    Private Sun Form_Click()

          ' Send ALT+TAB to Windows 95
          SendKeys "%{TAB}", True
          Debug.Print "ALT+TAB Sent"
    
       End Sub
    
    

  4. Press the F5 key to run the application.

  5. Click the form.

At this point, "ALT+TAB Sent" is displayed in the Debug Window (if the Debug Window is visible) but nothing else appearsto happen. This behavior is by design in Windows 95.

Under Windows 3.x, Windows for Workgroups, or Windows NT "ALT+TAB Sent" is displayed in the Debug Window (if the Debug Window is visible, and an application's title appears in the center of the screen and then disappears when that application becomes active.


Additional reference words: 4.00 Alt Tab Send Win95 vb4win vb4all
KBCategory: kbenv kbprb
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: October 30, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.