Jump to content

NumLock


Recommended Posts

I may be being stupid (in fact I'm almost certainly being stupid - such is usually the case...) but I can't change the state of the NumLock key with my script.

From the help file I assumed that if I added the line:

Send("{NumLock on}")

it should turn NumLock on if it wasn't already. However it doesn't seem to work.

Is there anything I'm missing (like a SendCapslockMode for the NumLock key or something?)

Thanks

Link to comment
Share on other sites

Send("{NUMLOCK on}")

works on mine

<{POST_SNAPBACK}>

Hmmmm

Can't seem to get it to work on my system though.

If I use the following:

Opt("SendCapslockMode", 0)

Send("{CAPSLOCK on}")

Then I can toggle the capslock key ok. It just doesn't do anything when I try to do the same for numlock.

Very puzzled...

Link to comment
Share on other sites

Again I can toggle the status of the capslock key, but numlock remains unchanged.

Are there any other options etc that need to be changed for this to work?

I am using a separate keyboard and keypad if this makes any difference, and so actually have 2 numlock buttons (one on the main keyboard and one on the keypad).

Could this be the problem? The Send command is somehow sending both buttons at once and cancelling itself out? If this is the case I can see how this would do nothing for the toggle command but not the set on or off option.

I thought this would be simple but my brain is starting to hurt...

Thanks for the help so far though.

Link to comment
Share on other sites

Again I can toggle the status of the capslock key, but numlock remains unchanged.

Are there any other options etc that need to be changed for this to work?

I am using a separate keyboard and keypad if this makes any difference, and so actually have 2 numlock buttons (one on the main keyboard and one on the keypad).

Could this be the problem?  The Send command is somehow sending both buttons at once and cancelling itself out?  If this is the case I can see how this would do nothing for the toggle command but not the set on or off option.

I thought this would be simple but my brain is starting to hurt...

Thanks for the help so far though.

<{POST_SNAPBACK}>

No special options, just had the one line of code in the script nothing else,

don't have the 2 numlocks so can't help you there.

SciTE for AutoItDirections for Submitting Standard UDFs

 

Don't argue with an idiot; people watching may not be able to tell the difference.

 

Link to comment
Share on other sites

I'm also using Win98SE on the computer I'm trying to get it to work on if that makes a difference, although I can switch it easily to WinXP if it'll help.

<{POST_SNAPBACK}>

you're using 2 keyboards on one computer on 98? neat. have to say i haven't seen that before... but question, is the numlock state being affected on either keyboard?
Link to comment
Share on other sites

One thing I would like to ask is when you press the numlock on one keyboard does it affect both?

If both lights are on does it work?

Just a couple of questions that popped into my head as I was reading this,

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
Share on other sites

I'm not using 2 keyboards as such - I have a a ps2 mini 'laptop style' keyboard with the silly keypad in the middle of all the other letters which is only active when NumLock is on, and also a separate usb numeric keypad. When NumLock is off, I can type fine on the mini keyboard but the numeric keypad operates in curser mode, when NumLock is on the keypad operates like a numeric keypad but half of the keyboard buttons give me letters not numbers when I type.

What I want my script to do is automatically switch NumLock on or off when I'm using different programs so I don't have to remember to press the key myself.

Pressing the NumLock key on either keyboard toggles the NumLock state on both, but nothing I do with AutoIt seems to have any affect whatsoever.

Any more help?

Edited by robj
Link to comment
Share on other sites

  • 5 months later...

I sought this forum to see if this was a reported problem. I hate having the keyboard power up with numlock enabled. I don't know if it came sooner but was pleased to find WinXP had solved the problem for me.

I tried NUMLOCK on the XP machine and it works as advertised on/off/toggle.

I have another machine running 98se but the BIOS allows me to power up numlock OFF.

A third 98se machine powers up with numlock on so I decided to write a script to shut it off on boot but was dismayed when it wouldn't work.

I can report on both 98se machines:

Send("{NUMLOCK on}")

Send("{NUMLOCK off}")

Send("{NUMLOCK toggle}")

have no effect whatsoever in version 3.1.1.0 when executed under Win98se.

Link to comment
Share on other sites

Hmm, maybe http://www.rjlsoftware.com/software/utility/numlock/ ]this website has the answer:

Windows 95/98/ME systems are not supported by this program. The API interface does not work for the NUM lock key. It only works on Windows NT/2K

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
Share on other sites

While this isn't perfect it works for me.

Although it worked first time every time in the debugger

in practice I had to place 2 short cuts in the startup

folder, running the program twice, to get the light to go out.

Additionally you have to smack the Num Lock key several

after running to get it in sync again with the light.

I rarely use num lock so I can live with that. At least that

damn light is extinguished.

#include <windows.h>

#include <stdio.h>

#define VK_NUMLOCK 0x90

#define KEYEVENTF_KEYUP 0x02

int main (void)

{

BYTE key[256];

BOOL bResult=0;

OSVERSIONINFO osVer;

osVer.dwOSVersionInfoSize = sizeof(osVer);

bResult = GetVersionEx(&osVer);

bResult= GetKeyboardState( (LPBYTE)&key[0]);

if(osVer.dwMajorVersion <5)

{

key[VK_NUMLOCK] &= 254; //11111110

bResult= SetKeyboardState( (LPBYTE)&key[0]);

}

else

if(key[VK_NUMLOCK] & 1 == 1)

{

keybd_event( VK_NUMLOCK, 0, 0, 0);

keybd_event( VK_NUMLOCK, 0, KEYEVENTF_KEYUP, 0);

}

return 0;

}

/*

Remarks

Because the SetKeyboardState function alters the input state of the calling

thread and not the global input state of the system, an application cannot use

SetKeyboardState to set the NUM LOCK, CAPS LOCK, or SCROLL LOCK indicator lights

on the keyboard.

*/

Link to comment
Share on other sites

  • 1 month later...

I may be being stupid (in fact I'm almost certainly being stupid - such is usually the case...) but I can't change the state of the NumLock key with my script.

From the help file I assumed that if I added the line:

Send("{NumLock on}")

it should turn NumLock on if it wasn't already. However it doesn't seem to work.

Is there anything I'm missing (like a SendCapslockMode for the NumLock key or something?)

Thanks

I know this is almost a year late but....

When you press the numlock on the USB keypad, does it also control the one on the keyboard or do the two numlocks seem to work independant? If they are independant try manually setting them both on, then press and hold the one on the USB keypad for about 1-2 seconds, then release it. Now try toggling the USB one and note if it now controls the keyboard as well. I can't remember if, once sync'd, the opposite is true and the main keyboard will also control the keypad.

Basically, most USB keypads work on their own with their own circuitry to control the numlock. Some have an option, though, to toggle whether the USB keypad will control the keyboard as well simply by holding down the numlock for a moment. Also note, if you start with the two numlock lights opposite (one active, the other not) then once you "sync" them they will continue to be opposite all the time.

Hope this helps someone out there.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...