|
Prev: Automatic Login using Visual Basic or Batch script
Next: stellenangebot hamburg arbeitsangebot deutschland Schweisser Schweißerin stellenangebote koeln stellenangebot pharma stellenangebote klinikum Werbetexter Werbetexterin stellenangebot wien stellenangebot mannheim
From: RB Smissaert on 6 Jul 2008 06:32 I have a login routine where I turn on numlock to avoid login errors due to this not being turned on. This makes sense on the great majority of machines where there is a numeric keypad. It is no good though on machines where this isn't present as it will make certain letter keys (j, k, l etc.) come out as numbers. So, how do I detect this situation? Had a good look on the net for this, but so far not any solution and I am sure there must be some simple code that will detect this. RBS
From: RB Smissaert on 6 Jul 2008 08:03 Forget about this, the GetKeyboardLayoutName API should do the job. RBS "RB Smissaert" <bartsmissaert(a)blueyonder.co.uk> wrote in message news:OTYIhO13IHA.4800(a)TK2MSFTNGP02.phx.gbl... >I have a login routine where I turn on numlock to avoid login errors due to >this not being turned on. > This makes sense on the great majority of machines where there is a > numeric keypad. It is no good though > on machines where this isn't present as it will make certain letter keys > (j, k, l etc.) come out as numbers. > So, how do I detect this situation? Had a good look on the net for this, > but so far not any solution and I am > sure there must be some simple code that will detect this. > > RBS
From: RB Smissaert on 6 Jul 2008 12:06 I thought this should do the job but it doesn't. I have this code to see if doing a NumLock is OK: Private Const KL_NAMELENGTH As Long = 9 Private Const KT_TYPE As Long = 0 Private Declare Function GetKeyboardLayoutName _ Lib "user32" _ Alias "GetKeyboardLayoutNameA" _ (ByVal pwszKLID As String) As Long Private Declare Function GetKeyboardType _ Lib "user32" (ByVal nTypeFlag As Long) As Long Function GetTypeOfKeyboard() As Long 'of these only 2 and 4 seem OK for Numlock '----------------------------------------- '1 IBM PC/XT or compatible (83-key) keyboard" '2 Olivetti "ICO" (102-key) keyboard" '3 IBM PC/AT (84-key) or similar keyboard" '4 IBM enhanced (101- or 102-key) keyboard" '5 Nokia 1050 and similar keyboards" '6 Nokia 9140 and similar keyboards" '7 Japanese keyboard" 'Else Unknown" Dim strName As String 'Create a buffer strName = String(KL_NAMELENGTH, 0) 'Get the keyboard layout name GetKeyboardLayoutName strName GetTypeOfKeyboard = GetKeyboardType(KT_TYPE) End Function But it gives me 4 both in the normal/usual keyboard and the laptop keyboard with no numeric keypad. So, it looks I somehow have to simulate a keypress and detect the effect of that. RBS "RB Smissaert" <bartsmissaert(a)blueyonder.co.uk> wrote in message news:eKeAPB23IHA.2064(a)TK2MSFTNGP02.phx.gbl... > Forget about this, the GetKeyboardLayoutName API should do the job. > > RBS > > > "RB Smissaert" <bartsmissaert(a)blueyonder.co.uk> wrote in message > news:OTYIhO13IHA.4800(a)TK2MSFTNGP02.phx.gbl... >>I have a login routine where I turn on numlock to avoid login errors due >>to this not being turned on. >> This makes sense on the great majority of machines where there is a >> numeric keypad. It is no good though >> on machines where this isn't present as it will make certain letter keys >> (j, k, l etc.) come out as numbers. >> So, how do I detect this situation? Had a good look on the net for this, >> but so far not any solution and I am >> sure there must be some simple code that will detect this. >> >> RBS >
From: Jim Mack on 6 Jul 2008 13:02 RB Smissaert wrote: > I have a login routine where I turn on numlock to avoid login > errors due to this not being turned on. > This makes sense on the great majority of machines where there is a > numeric keypad. It is no good though > on machines where this isn't present as it will make certain letter > keys (j, k, l etc.) come out as numbers. > So, how do I detect this situation? Had a good look on the net for > this, but so far not any solution and I am > sure there must be some simple code that will detect this. I can't be any help, and I'm sure you won't be dissuaded, but this seems to me a waste of time and unlikely, in the end, to make a good difference. If a login fails, just put up a message box explaining what might have gone wrong (e.g. numlock off, capslock on etc). Doesn't Windows do just that, so wouldn't users expect it? People generally know how to log in, and if they don't they need to learn. Holding hands might seem like a favor to the user, but you can go too far. Of course there are different schools of thought on this topic, but I've never been of the opinion that users are too dumb to learn from mistakes. -- Jim
From: RB Smissaert on 6 Jul 2008 13:41
Yes, you are right there, maybe this is going a bit too far, but on the other hand, surely there must be a simple way to detect this situation and if there is you might as well correct it. How come it is so difficult to detect that a press on the j key produces a 1 instead of a j? RBS "Jim Mack" <jmack(a)mdxi.nospam.com> wrote in message news:e8SFEo43IHA.784(a)TK2MSFTNGP04.phx.gbl... > RB Smissaert wrote: >> I have a login routine where I turn on numlock to avoid login >> errors due to this not being turned on. >> This makes sense on the great majority of machines where there is a >> numeric keypad. It is no good though >> on machines where this isn't present as it will make certain letter >> keys (j, k, l etc.) come out as numbers. >> So, how do I detect this situation? Had a good look on the net for >> this, but so far not any solution and I am >> sure there must be some simple code that will detect this. > > I can't be any help, and I'm sure you won't be dissuaded, but this > seems to me a waste of time and unlikely, in the end, to make a good > difference. > > If a login fails, just put up a message box explaining what might have > gone wrong (e.g. numlock off, capslock on etc). Doesn't Windows do > just that, so wouldn't users expect it? > > People generally know how to log in, and if they don't they need to > learn. Holding hands might seem like a favor to the user, but you can > go too far. Of course there are different schools of thought on this > topic, but I've never been of the opinion that users are too dumb to > learn from mistakes. > > -- > Jim > |