INFO: Visual Basic SendKeys Statement Is Case-Sensitive

Last reviewed: September 29, 1997
Article ID: Q81466

The information in this article applies to:

- Standard and Professional Editions of Microsoft Visual Basic for

  Windows, versions 2.0, 3.0
- Microsoft Visual Basic programming system for Windows, version 1.0

SUMMARY

The SendKeys statement in Microsoft Visual Basic for Windows is case- sensitive with regards to the keystrokes sent. Sending an uppercase letter may be interpreted by the receiving application differently than the lowercase version of a letter.

MORE INFORMATION

The following line of code sends an ALT+F key combination to the application that currently has the focus:

   SendKeys "%(F)"

NOTE: This is different from ALT+F:

   SendKeys "%(f)"

This can be a problem because some applications distinguish between an uppercase F and lowercase f when sent by the SendKeys statement.

For example, Microsoft Word versions 1.0b and earlier for Windows (WINWORD.EXE) do not distinguish the difference. However, Microsoft Word version 2.0 for Windows does distinguish the lowercase f sent by SendKeys.

When SendKeys (from Visual Basic for Windows) sends the ALT+F key combination, WINWORD.EXE version 2.0 interprets the keystroke as ALT+Shift+f, at which Word for Windows will simply beep. However, SendKeys using ALT+f will correctly activate the File menu.

Keywords          : PrgCtrlsStd vbwin GnrlVb kbprg kbfasttip
Technology        : kbvba
Version           : WINDOWS:2.0 3.0
Issue type        : kbinfo


================================================================================


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: September 29, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.