NumLock 
Author Message
 NumLock

Is it possible to disable the "Numlock" key?

I've created a "time-clock" program where different users type in their code
number followed by enter.
The program then writes the code number and the start time in a file and
when that same user types his number again it also writes the end time to
that record. Fairly easy and works fine
But most of those users aren't familiar with computers and sometimes it
happens that one users accidentally hits the numlock and when the following
user tries to input his data nothing happens.

Cobra



Sun, 29 Dec 2002 03:00:00 GMT  
 NumLock
Quote:

> Is it possible to disable the "Numlock" key?

Not terribly easy but this code should get you started.

o  GROUP(OSVERSIONINFO)
   END
NumLockState  Bool
ScrollLockState  Bool
CapsLockState  Bool
keys Byte,dim(256)
val1 byte
val2 byte
val3 ulong
val4 ulong

!caps button toggle
                  !Simulate Key Press
                    val1 =  VK_CAPITAL
                    val2 =  45H
                    val3 =  BOR(KEYEVENTF_EXTENDEDKEY,0)
                    val4 =  0
                    keybd_event(Val1, val2, val3, val4)
                  !Simulate Key Release
                    val1 =  VK_CAPITAL
                    val2 =  45H
                    val3 =  BOR(KEYEVENTF_EXTENDEDKEY,KEYEVENTF_KEYUP)
                    val4 =  0
                    keybd_event(Val1, val2, val3, val4)

!NumLock Key
               o.dwOSVersionInfoSize = size(o)
                GetVersionEx(o)
                GetKeyboardState(keys[1])

                ! NumLock handling:
                NumLockState = keys[VK_NUMLOCK+1]
                If NumLockState <> True Then    !Turn numlock on
                  If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then  
!===== Win95
                    keys[VK_NUMLOCK+1] = 1
                    SetKeyboardState(keys[1])
                  ElsIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then  
!===== WinNT
                  !Simulate Key Press
                    keybd_event (VK_NUMLOCK, 45h,
BOR(KEYEVENTF_EXTENDEDKEY,0),0)
                  !Simulate Key Release
                    keybd_event( VK_NUMLOCK, 45h,
BOR(KEYEVENTF_EXTENDEDKEY,KEYEVENTF_KEYUP), 0)

                  End
                else
                  If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then  
!===== Win95
                    keys[VK_NUMLOCK+1] = 0
                    SetKeyboardState(keys[1])
                  ElsIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then  
!===== WinNT
                  !Simulate Key Press
                    keybd_event (VK_NUMLOCK, 45h,
BOR(KEYEVENTF_EXTENDEDKEY,0),0)
                  !Simulate Key Release
                    keybd_event( VK_NUMLOCK, 45h,
BOR(KEYEVENTF_EXTENDEDKEY,KEYEVENTF_KEYUP), 0)

                  End
                  !Message('NumLock is on')
                End
                Display

-----------------
Jim Kane  - TeamTopSpeed
Productive Software Solutions
Can't Find that Message?
Get Organized, Get ForKeeps!
www.fkeeps.com



Sun, 29 Dec 2002 03:00:00 GMT  
 NumLock
Quote:

> What happens under 9x if you also start changing the numlock state manually
> by pressing the numlock key?

I dont know - I've never tried.  Other than getkeyboardstate(), I dont know
another way to tell the state.
--------------------
Jim Kane  - TeamTopSpeed
Productive Software Solutions
Can't Find that Message?
Get Organized, Get ForKeeps!
www.fkeeps.com


Mon, 30 Dec 2002 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Numlocks on numeric fields

2. NumLock & CapLock control

3. Toggle NumLock in 32-bit app under Win95

4. Setting NumLock On Automatically

5. NUMLOCK not Synchonizing in Win2K

6. Toggling CapsLock and NumLock?

7. How can I force the NumLock to ON?

8. Numlock

9. NumLock

10. How to turn on NUMLOCKS

11. Numlock

12. New version of Poplog and Numlock

 

 
Powered by phpBB® Forum Software