TIP: Click on subject to list as thread! ANSI
echo: qedit
to: ALL
from: MICHAEL DURLAND
date: 1997-09-13 02:39:00
subject: Re: How to set capslock in TSE Pro/32

From: Michael Durland 
At 10:24 AM 9/12/97 -0400, Sammy Mitchell wrote:
>Does anyone know how to set capslock on in Windows NT via a 32-bit console
program? =20
...
>Sammy Mitchell
>SemWare Corp.
Microsoft Knowledge Base Article Q127190 describes how to toggle the NUM
LOCK, CAPS LOCK, and SCROLL LOCK.  I have pasted in the article at the end
of this email.
I hope this helps.
Mike Durland
mdurland@altera.com
-------------------------------------------------------
How To Toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK Keys
Article ID: Q127190=20
Creation Date: 14-MAR-1995
Revision Date: 10-OCT-1996=20
The information in this article applies to:=20
=95Microsoft Win32 Application Programming Interface (API) included with:=20
    - Microsoft Windows NT versions 3.5 and 3.51
    - Microsoft Windows 95 version 4.0
SUMMARY=20
The documentation for SetKeyboardState() correctly says that you cannot use
this API to toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK keys.=20
You can use keybd_event() to toggle the NUM LOCK, CAPS LOCK, and SCROLL
LOCK keys under Windows NT. The same technique works for toggling CAPS LOCK
and SCROLL LOCK under Windows 95, but it will not work for NUM LOCK.=20
MORE INFORMATION=20
The following sample program turns the NUM LOCK light on if it is off. The
SetNumLock function defined here simulates pressing the NUM LOCK key, using
keybd_event() with a virtual key of VK_NUMLOCK. It takes a boolean value
that indicates whether the light should be turned off (FALSE) or on (TRUE).=
=20
The same technique can be used for the CAPS LOCK key (VK_CAPITAL) and the
SCROLL LOCK key (VK_SCROLL).=20
Sample Code=20
/* Compile options needed: */=20
#include =20
void SetNumLock( BOOL bState ) {=20
   BYTE keyState[256];
   GetKeyboardState((LPBYTE)&keyState);
   if( (bState && !(keyState[VK_NUMLOCK] & 1)) ||
       (!bState && (keyState[VK_NUMLOCK] & 1)) )
   {
   // Simulate a key press
      keybd_event( VK_NUMLOCK,
                   0x45,
                   KEYEVENTF_EXTENDEDKEY | 0,
                   0 );
   // Simulate a key release
      keybd_event( VK_NUMLOCK,
                   0x45,
                   KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
                   0);
   }
}=20
void main() {=20
   SetNumLock( TRUE );
}=20
------------------------------------------------------------------------
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.=20
=A91997 Microsoft Corporation. All rights reserved. Legal Notices.
Additional reference words: 3.50 4.00 95
KBCategory: kbui kbcode
KBSubcategory: UsrInp
---
---------------
* Origin: apana>>>>>fidonet [sawasdi.apana.org.au] (3:800/846.13)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.