Number lock

Kelly Burgess kellyb at
Mon May 24 11:33:24 UTC 2021

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 -
> 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

More information about the omnisdev-en mailing list