Controlling keyboard LED

This is a discussion on Controlling keyboard LED within the Windows Programming forums, part of the Platform Specific Boards category; Is there any way to control keyboard LED-s with Win32 API? C++, Win32, Dev-C++...

  1. #1
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318

    Controlling keyboard LED

    Is there any way to control keyboard LED-s with Win32 API?

    C++, Win32, Dev-C++

  2. #2
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    The docs say:
    Quote Originally Posted by MSDN SetKeyboardState
    Because the SetKeyboardState function alters the input state of the calling thread and not the global input state of the system, an application cannot use SetKeyboardState to set the NUM LOCK, CAPS LOCK, or SCROLL LOCK (or the Japanese KANA) indicator lights on the keyboard. These can be set or cleared using SendInput to simulate keystrokes.

    Windows NT/2000/XP: The keybd_event function can also toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK keys.

    Windows 95/98/Me: The keybd_event function can toggle only the CAPS LOCK and SCROLL LOCK keys. It cannot toggle the NUM LOCK key.
    I think you can get the current state with either GetAsyncKeyState or GetKeyboardState.

  3. #3
    Registered User
    Join Date
    Aug 2006
    Location
    England
    Posts
    5
    Code:
    keybd_event(VK_CAPITAL, 0, 0, 0);               // this turns caps on
    keybd_event(VK_CAPITAL, 0, KEYEVENTF_KEYUP, 0); // this turns caps off

  4. #4
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    The same thing possible with SendInput?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Detecting keyboard and mouse in linux
    By sameer.nalwade in forum C Programming
    Replies: 3
    Last Post: 11-22-2008, 04:24 AM
  2. Keyboard port using other that a keyboard
    By antoinelac in forum C++ Programming
    Replies: 4
    Last Post: 06-12-2008, 03:46 PM
  3. Switch function problem
    By ahming in forum C Programming
    Replies: 3
    Last Post: 04-01-2008, 10:40 AM
  4. Virtual keys
    By Arkanos in forum Windows Programming
    Replies: 4
    Last Post: 12-12-2005, 10:00 AM
  5. Game Design Topic #2 - Keyboard or Mouse?
    By TechWins in forum Game Programming
    Replies: 4
    Last Post: 10-08-2002, 04:34 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21