Solved

Turn Caps Lock on and off

Posted on 1998-09-28
3
243 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
Comment Utility
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
Comment Utility
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
Comment Utility
Good point
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

744 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