Num, Caps and Scroll Lock state? 
Author Message
 Num, Caps and Scroll Lock state?

Hi guys,

While Googling, I noticed that a few people have asked before about how
to get the initial Num, Caps and Scroll Lock states.

The responses to the queries back then were essentially: "There's no way
to do this in TCL, you'll need to produce a binary library for each
platform".

Did anyone ever do this? I'd hate to attempt to reinvent the wheel a
number of times to cover a range of operating systems, especially since
my C is very rusty ;-).

Thanks.



Tue, 25 Mar 2008 02:24:48 GMT  
 Num, Caps and Scroll Lock state?

Quote:

> While Googling, I noticed that a few people have asked before about how
> to get the initial Num, Caps and Scroll Lock states.

> The responses to the queries back then were essentially: "There's no way
> to do this in TCL, you'll need to produce a binary library for each
> platform".

You can look here: http://wiki.tcl.tk/4238

However, I have found reliably that the shift, control and
caps_lock bits are reliable across platforms (maybe even
the num_lock, but I can't test right now since I have an
Apple keyboard on the OS X/Linux kvm ... they don't have a
num_lock).

In any case, you will also find that the LMR mousebutton bit
is portable (at least Win/Lin/OS X).  Try this:

destroy .t
toplevel .t
bind .t <Key> [list keystate %A %K %N %k %s]

proc keystate {A K N k s} {
     set bits [list]
     foreach {bit id} {
        1024 "1024-bit RMB"
        512 "512-bit MMB"
        256 "256-bit LMB"
        128 "128-bit ??"
        64 "64-bit ??"
        32 SCROLL_LOCK(WIN)
        16 "16-bit ??"
        8 NUM_LOCK
        4 CONTROL
        2 CAPS_LOCK
        1 SHIFT
     } {
        if {$s & $bit} {
            lappend bits $id
        }
     }

     puts [list KEY $A SYM $K $N CODE $k STATE $s ($bits)]

Quote:
}

--
   Jeff Hobbs, The Tcl Guy
   http://www.ActiveState.com/, a division of Sophos


Tue, 25 Mar 2008 03:40:22 GMT  
 Num, Caps and Scroll Lock state?

Quote:


>> While Googling, I noticed that a few people have asked before about how
>> to get the initial Num, Caps and Scroll Lock states.
>> The responses to the queries back then were essentially: "There's no way
>> to do this in TCL, you'll need to produce a binary library for each
>> platform".

> You can look here: http://wiki.tcl.tk/4238

> However, I have found reliably that the shift, control and
> caps_lock bits are reliable across platforms (maybe even
> the num_lock, but I can't test right now since I have an
> Apple keyboard on the OS X/Linux kvm ... they don't have a
> num_lock).

> In any case, you will also find that the LMR mousebutton bit
> is portable (at least Win/Lin/OS X).  Try this:

> destroy .t
> toplevel .t
> bind .t <Key> [list keystate %A %K %N %k %s]

> proc keystate {A K N k s} {
>     set bits [list]
>     foreach {bit id} {
>     1024 "1024-bit RMB"
>     512 "512-bit MMB"
>     256 "256-bit LMB"
>     128 "128-bit ??"
>     64 "64-bit ??"
>     32 SCROLL_LOCK(WIN)
>     16 "16-bit ??"
>     8 NUM_LOCK
>     4 CONTROL
>     2 CAPS_LOCK
>     1 SHIFT
>     } {
>     if {$s & $bit} {
>         lappend bits $id
>     }
>     }

>     puts [list KEY $A SYM $K $N CODE $k STATE $s ($bits)]
> }

BTW, I should add to the above that I found the 16-bit to
always trigger on Linux using the OS X keyboard ... but I
didn't have any indication of what it was.  Also, the
64-bit was triggering for the OS X Command key, and the
option/alt key was triggering NUM_LOCK.

--
   Jeff Hobbs, The Tcl Guy
   http://www.ActiveState.com/, a division of Sophos



Tue, 25 Mar 2008 03:44:47 GMT  
 Num, Caps and Scroll Lock state?

Quote:

> BTW, I should add to the above that I found the 16-bit to
> always trigger on Linux using the OS X keyboard ... but I
> didn't have any indication of what it was.  Also, the
> 64-bit was triggering for the OS X Command key, and the
> option/alt key was triggering NUM_LOCK.

Hi Jeff. Thanks for that info. Excellent stuff :-).


Tue, 25 Mar 2008 16:00:42 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. num lock, caps lock, scroll lock lights

2. a traffic light program with lock's (num loack Caps loack and scroll lock)

3. how to display Num and Caps Lock state on status bar

4. Num Lock and Caps Lock

5. Q: Determing num/caps lock status

6. {caps,num}lock - once more for the record

7. Scroll, Caps and Num blink

8. how to on/off num lock, caps lock, scroll lock ???

9. Scrolling & CAPS-LOCK key

10. KBD CAPS/NUM LED Indicators

11. DOS utility that controls Caps Lock & Num Lock keys

12. Num Lock with PB3.20

 

 
Powered by phpBB® Forum Software