AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

NumLock Detector

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions
View previous topic :: View next topic  
Author Message
scouchman



Joined: 28 Apr 2004
Posts: 45

PostPosted: Mon Mar 20, 2006 10:39 pm    Post subject: NumLock Detector Reply with quote

Finally I have a generic enough bit of code I can share!

Code:
#InstallKeybdHook
#Persistent

SetTimer, NetMeetingNumLock, 1000
return

NetMeetingNumLock:
IfNotEqual, Skipcheck, 1
 {
  IfWinExist, NetMeeting -
  {
   NLstate := GetKeyState("Numlock", "T")
   Skipcheck = 1
   SetNumLockState, AlwaysOff
  }
 }
IFEqual, Skipcheck, 1
 {
  IfWinNotExist, NetMeeting -
   {
    IfEqual, NLstate, 1
      SetNumLockState, On
    Else
      SetNumLockState,
    Skipcheck = 0
   }
  }
Return


Okay, so where I work, we use NetMeeting all the time to connect to client laptops remotely. The IBM T43 for some reason detects the Numlock state through the netmeeting and turns it on on the T43. And when the netmeeting is disconnected, it leaves it on on the T43. This script will force Numlock to stay off only when Netmeeting is running, and it will return the Numlock state after Netmeeting is gone.

(For more general use, I know there are some games that for no good reason turn off Numlock, and this could be modified for that, or hopefully other uses)

So two questions:
1. is there any way to optimize this further?
2. A weird situation occurs with other laptops having this on their systems. If whoever is running this, has their own laptop Numlock on (personally, I don't know anyone who does), so "uio" would type "456", then this script appears to work fine except:
on a HP/Compaq 6000, it says that numlock is back on, but it isn't. You'd have to manually hit numlock twice (off, then back on) to turn it back on.
On a Toshiba M2, when the Numlock turns off, it actually sets the "uio" to left arrow, null, right arrow. Turns back on okay, though.

Any of the scenarios I've run, it works fine with an external keyboard connected, so I'm not really concerned, but any clue why these laptops do the weird things?
_________________
Scott F Couchman
Back to top
View user's profile Send private message AIM Address MSN Messenger
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10480

PostPosted: Wed Mar 22, 2006 1:40 am    Post subject: Reply with quote

Although I can't explain these issues offhand, I've observed that Numlock is has more quirks than Capslock and Scroll-Lock. I'm not sure why that is -- probably something innate to the OS or drivers.

Thanks for the script.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Scripts & Functions All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group