Number lock

kim at kim at
Mon May 24 12:28:07 UTC 2021

Hi Kelly
 Thank you again.
I have implemented your code and it is working the way I would like.
My program is the main program with only occasional office which is better
if the number lock is on all the time.
(running win 10 or Server 16 and OS 10.2)


-----Original Message-----
From: omnisdev-en <omnisdev-en-bounces at> On Behalf Of
Kelly Burgess
Sent: Monday, 24 May 2021 9:33 PM
To: OmnisList <omnisdev-en at>
Subject: Re: Number lock

Hi Kim,

I did get that keybd_event API to work with Register/Call DLL - I'd been
registering it wrong.  Here's how it should go for numLock -  144 is the
virtual key, 69 is the scan code.

   Register DLL ('user32','keybd_event','VJJJJ')
   Call DLL ('user32','keybd_event',144,69,1,0)      ;; key press
   Call DLL ('user32','keybd_event',144,69,3,0)      ;; key release

For capsLock it was 20,58 for the vkey,scancode.

One thing to note is you can't immediately follow that code with another
call to GetKeyState and see the change, because the keyboard events won't
have been processed yet.  And remember the caution about not ticking people
off, if your app isn't the only thing running on the computer.  You could
use $omnistofront, note the current state, do what you need to do, and
restore the state on quitting or $omnistoback.


> On May 24, 2021, at 5:09 AM, Kelly Burgess <kellyb at> wrote:
> Hi Kim,
>> is there a command that if result=0 that you can automatically set 
>> result to 1
> I see an example of how to do that here -
> keybd_event?redirectedfrom=MSDN
> but I haven't been able to get Register/Call DLL to work with the
keybd_event function.  You could probably write an xcomp to do it.
> And I also saw several commenters saying 'please don't do that unless the
machine is dedicated to your app, otherwise users will find it Very Annoying
when you switch that global setting on them...'
> Kelly

Manage your list subscriptions at Start a new
message -> mailto:omnisdev-en at 

This email has been checked for viruses by AVG.

More information about the omnisdev-en mailing list