473,787 Members | 2,798 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Interacting with keyboard LEDs

Is there a way to interact with keyboard LEDs (for Caps/Scroll/Num
Lock) in Python? I'd like to achieve an effect similar to the *NIX
command "setleds -L", but I'm not sure where to start, but I figured
someone out there would have an idea or maybe experience with something
similar. Thanks very much in advance for your help!

Chris

Dec 9 '06 #1
4 3397
On Friday 08 December 2006 23:18, Chris Lasher wrote:
Is there a way to interact with keyboard LEDs (for Caps/Scroll/Num
Lock) in Python? I'd like to achieve an effect similar to the *NIX
command "setleds -L", but I'm not sure where to start, but I figured
someone out there would have an idea or maybe experience with something
similar. Thanks very much in advance for your help!

Chris
Spur of the moment answer: call setleds program from within your program

better answer (fox X11):
http://python-xlib.sourceforge.net/d...n-xlib_16.html

Take a look at get_keyboard_co ntrol() and change_keyboard _control(). As far as
knowing how to properly invoke them, I have no idea, maybe you could google
for examples or take a look at the setleds source?

- Jonathan
Dec 9 '06 #2
Jonathan Curran wrote:
Spur of the moment answer: call setleds program from within your program

better answer (fox X11):
http://python-xlib.sourceforge.net/d...n-xlib_16.html

Take a look at get_keyboard_co ntrol() and change_keyboard _control(). As far as
knowing how to properly invoke them, I have no idea, maybe you could google
for examples or take a look at the setleds source?

- Jonathan
Thanks for your reply, Jonathan. The difficulty with setleds is that
only works from a virtual console (e.g., tty, CTRL+ALT+F1 through F6,
etc.), not from a terminal emulator inside X (e.g., pts, Xterm, Gnome
Terminal, Konsole, etc.), which is the environment where I'd like to
interact with the LEDs. The xlib package looks promising, though. One
thing I don't understand is the 32-bit mask. How does this represent
the LED states? I profess my ignorance.

Thanks!
Chris

Dec 9 '06 #3
Chris,
I googled for {xlib caps led} and the first link was to a forum post:
http://forums.whirlpool.net.au/forum...fm/619126.html

The third post down, the guy made a program to set the LED of his scroll lock
key. The C source is at http://members.optusnet.com.au/foonly/hddled.c

If you can manage to convert his code into python w/python-xlib you will be
set. When you do, e-mail me the snippet will you ;)

- Jonathan
Dec 9 '06 #4
"Chris Lasher" <ch**********@g mail.comwrote:
8<-------------------------------
interact with the LEDs. The xlib package looks promising, though. One
thing I don't understand is the 32-bit mask. How does this represent
the LED states? I profess my ignorance.
not sure if this will be of any use - but when you talk to the keyboard, then on
the wire, the bits are in a byte as follows:

LEDS EQU GBITS1 ;LEDS FOR OUTPUT TO KEYBOARD

SCROLL_LOCK_BIT EQU LEDS.0 ; - least significant bit
NUM_LOCK_BIT EQU LEDS.1 ; - bit 1
CAPS_LOCK_BIT EQU LEDS.2 ; - bit 2

They are set following a mode indicator command to the keyboard which is 0xED
I just happen to know this because we made a funny keyboard wedge box once.

Haven't a clue about how xlib achieves this, though...

- Hendrik

Dec 10 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
2533
by: skearney | last post by:
When I was in boy scouts, as part of learning Morse code, I was told that the inventor of the typewriter originally put the letter 'e' under the left middle finger, just below its present position. The typist was often too fast and the print bars would jam. I heard the same story when I took a typing class. This led me to wonder if 't' might have been moved from the home row for the same reason. 'E is dit and T is dash, under middle...
13
2765
by: Steve Jorgensen | last post by:
Well, it seems that Microsoft, or whatever powers that be have decided it's time for us to have yet another standard keyboard layout change. I think I see that the point of this one was to reduce the space occupied by the keys on the right, so the reach to the mouse is not so bad, but the way they chose to do it? Ah - I see. Since most of what we type will simply be deleted at some point, let's make sure the Delete key is big and easy...
23
7753
by: herrcho | last post by:
What's the difference between STDIN and Keyboard buffer ? when i get char through scanf, i type in some characters and press enter, then, where do the characters go ? to STDIN or Keyboard buffer ? are they same ? thanks ^^
7
10697
by: Don Riesbeck Jr. | last post by:
I'm working on an application (OEM) using C# that utilizes input from a keyboard, and USB Barcode Scanner. The scanner is a HID Keyboard device, and input from it is sent to the system as if it were a keyboard. I need to be able to identify input from the scanner and keyboard independently. I've looked at DirectX.DirectInput, and using user32.dll to hook into the keyboard messages, but neither method seems to allow for identification of...
0
6735
by: rs | last post by:
Hi guys, I am trying to read from a USB keyboard using vb.net and HID classes. the USB keyboard is not my primary keyboard. I have a ps2 keyboard connected and is detected in device manager as my keyboard. the USB keyboard is detected as HID keyboard device. the program finds the keyboard if it is attached. and I am getting valid handles. however, everytime I use the readfile function I am getting "object reference not set to an instant...
2
8771
by: rs | last post by:
Hi guys, I am trying to read from a USB keyboard using vb.net and HID classes. the USB keyboard is not my primary keyboard. I have a ps2 keyboard connected and is detected in device manager as my keyboard. the USB keyboard is detected as HID keyboard device. the program finds the keyboard if it is attached. and I am getting valid handles. however, everytime I use the readfile function I am getting "object reference not set to an instant...
4
4166
by: Melson | last post by:
Hi Can anyone help. I would like to replace the keys on the PC keyboard. For example, when I press Q button it displays A on the screen in any programs (MS Words, Note, Lotus....). And also when I press Ctrl + W button, it displays G on the screen. I would like to make the keyboards configurable. Should I write a Windows Service? Any suggestions would really appreciate. Please help. Thanks.
1
3037
by: yanz | last post by:
Hi everyone. Hope you guys can help me. Attached below are VB6 codes for a hand phone to call to a modem. When the action is executed, a message box will pop out ‘Ring Ring’. I just want to know is there anyone out there have the codes for SMS where when the action is executed, a message box will pop out. On the other hand, I also need some simple codes (VB6) for 8 LEDs lights for parallel ports. Below is the coding for the calling with...
331
14987
by: Xah Lee | last post by:
http://xahlee.org/emacs/modernization.html ] The Modernization of Emacs ---------------------------------------- THE PROBLEM Emacs is a great editor. It is perhaps the most powerful and most versatile text editor. And, besides text editing, it also serves as a
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9964
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4067
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.