Solved

Turn Caps Lock on and off

Posted on 1998-09-28
3
248 Views
Last Modified: 2012-06-27
Hello!

I wonder if it is possible to force the keys Caps lock,Num lock, or Scroll lock to be on or off at a certain time in my aplication.

How do I do?

mrc
0
Comment
Question by:mrc121197
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 0 total points
ID: 1173916
BYTE abyKeys[256] ;

::GetKeyboardState( abyKeys ) ;

abyKeys[ VK_whatever ] |= 1 ; // set toggle key on
abyKeys[ VK_whatever ] &= ~1 ; // set toggle key off

::SetKeyboardState( abyKeys ) ;

Docs are in GetKeyboardState API

0
 
LVL 22

Expert Comment

by:nietod
ID: 1173917
Note that this technique does not affect the indicator lights on the keyboard and will not affect the caps lock etc status of other programs.

You can use keybd_event() to send "fake" key strokes to affect the indicator lights and to affect other processes.
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1173918
Good point
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now