Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Status of NumLock, ScrollLock and CapsLock

Good morning,

I'm SURE I found the answer to this on here somewhere, but I can't find it
now.
Can anybody please tell me how to determine the status of the lock keys -
that is, whether NumLock, ScrollLock and capsLock are on or off?

Thanks in advance

Pete


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 225
Default Status of NumLock, ScrollLock and CapsLock

Pete,

Search this group for GetKeyboardState and you'll find several
useful postings.


Peter Rooney wrote:
Good morning,

I'm SURE I found the answer to this on here somewhere, but I can't find it
now.
Can anybody please tell me how to determine the status of the lock keys -
that is, whether NumLock, ScrollLock and capsLock are on or off?

Thanks in advance

Pete


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Status of NumLock, ScrollLock and CapsLock

Andrew,
Interestingly enough, if I do, the only thread that's returned is this one.
Am I spelling it correctly - all one word?
Regards
Pete



"Andrew Taylor" wrote:

Pete,

Search this group for GetKeyboardState and you'll find several
useful postings.


Peter Rooney wrote:
Good morning,

I'm SURE I found the answer to this on here somewhere, but I can't find it
now.
Can anybody please tell me how to determine the status of the lock keys -
that is, whether NumLock, ScrollLock and capsLock are on or off?

Thanks in advance

Pete



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Status of NumLock, ScrollLock and CapsLock

http://groups.google.co.uk/groups?as...=2006&safe=off

or
http://snipurl.com/png3



Peter Rooney wrote:

Andrew,
Interestingly enough, if I do, the only thread that's returned is this one.
Am I spelling it correctly - all one word?
Regards
Pete

"Andrew Taylor" wrote:

Pete,

Search this group for GetKeyboardState and you'll find several
useful postings.


Peter Rooney wrote:
Good morning,

I'm SURE I found the answer to this on here somewhere, but I can't find it
now.
Can anybody please tell me how to determine the status of the lock keys -
that is, whether NumLock, ScrollLock and capsLock are on or off?

Thanks in advance

Pete




--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 325
Default Status of NumLock, ScrollLock and CapsLock

Dave,

Thanks for the advice, but the links seem to go somewhere that doesn't
relate to doing it in Excel,
and I'm not clever enough to adapt it. Either that, or I'm just not used to
using Google groups properly! :O)

Pete




"Dave Peterson" wrote:

http://groups.google.co.uk/groups?as...=2006&safe=off

or
http://snipurl.com/png3



Peter Rooney wrote:

Andrew,
Interestingly enough, if I do, the only thread that's returned is this one.
Am I spelling it correctly - all one word?
Regards
Pete

"Andrew Taylor" wrote:

Pete,

Search this group for GetKeyboardState and you'll find several
useful postings.


Peter Rooney wrote:
Good morning,

I'm SURE I found the answer to this on here somewhere, but I can't find it
now.
Can anybody please tell me how to determine the status of the lock keys -
that is, whether NumLock, ScrollLock and capsLock are on or off?

Thanks in advance

Pete



--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 718
Default Status of NumLock, ScrollLock and CapsLock

Const VK_CAPITAL = &H14
Const VK_NUMLOCK = &H90
Const VK_SCROLL = &H91
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type

Private Declare Function GetKeyboardState Lib "user32" (kbArray As
KeyboardBytes) As Long


Sub testkb()
Dim kb As KeyboardBytes
GetKeyboardState kb
MsgBox _
"NumLock: " & kb.kbByte(VK_NUMLOCK) & vbLf & _
"ScrollLock : " & kb.kbByte(VK_SCROLL) & vbLf & _
"CapslLock : " & kb.kbByte(VK_CAPITAL)
End Sub

HTH
--
AP

"Peter Rooney" a écrit dans le
message de ...
Good morning,

I'm SURE I found the answer to this on here somewhere, but I can't find it
now.
Can anybody please tell me how to determine the status of the lock keys -
that is, whether NumLock, ScrollLock and capsLock are on or off?

Thanks in advance

Pete




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Status of NumLock, ScrollLock and CapsLock

It's a link to a Google Groups Search page. Click on a few of those links and
you'll see lots of suggestions...


I've saved this from other posts.

Option Explicit
' Code from "VBA Developer's Handbook" (Sybex, 1997):
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) _
As Integer
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) _
As Long
Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) _
As Long
Function GetCapslock() As Boolean
' Return or set the Capslock toggle
GetCapslock = CBool(GetKeyState(vbKeyCapital) And 1)
End Function
Function GetNumlock() As Boolean
' Return or set the Numlock toggle.
GetNumlock = CBool(GetKeyState(vbKeyNumlock) And 1)
End Function
Sub SetCapslock(Value As Boolean)
' Return or set the Capslock toggle.
Call SetKeyState(vbKeyCapital, Value)
End Sub
Sub SetNumlock(Value As Boolean)
' Return or set the Numlock toggle.
Call SetKeyState(vbKeyNumlock, Value)
End Sub
Private Sub SetKeyState(intKey As Integer, fTurnOn As Boolean)
Dim abytBuffer(0 To 255) As Byte
GetKeyboardState abytBuffer(0)
abytBuffer(intKey) = CByte(Abs(fTurnOn))
SetKeyboardState abytBuffer(0)
End Sub
Sub Caps_on()
If GetCapslock = False Then Call SetKeyState(vbKeyCapital, True)
End Sub
Sub Caps_Off()
If GetCapslock = True Then Call SetKeyState(vbKeyCapital, False)
End Sub
Sub auto_open()
Application.OnKey "{CAPSLOCK}", "TurnItOff"
End Sub
Sub auto_close()
Application.OnKey "{CAPSLOCK}"
End Sub
Sub TurnItOff()
If GetCapslock = True Then
Call SetKeyState(vbKeyCapital, False)
Beep
End If
End Sub

Peter Rooney wrote:

Dave,

Thanks for the advice, but the links seem to go somewhere that doesn't
relate to doing it in Excel,
and I'm not clever enough to adapt it. Either that, or I'm just not used to
using Google groups properly! :O)

Pete

"Dave Peterson" wrote:

http://groups.google.co.uk/groups?as...=2006&safe=off

or
http://snipurl.com/png3



Peter Rooney wrote:

Andrew,
Interestingly enough, if I do, the only thread that's returned is this one.
Am I spelling it correctly - all one word?
Regards
Pete

"Andrew Taylor" wrote:

Pete,

Search this group for GetKeyboardState and you'll find several
useful postings.


Peter Rooney wrote:
Good morning,

I'm SURE I found the answer to this on here somewhere, but I can't find it
now.
Can anybody please tell me how to determine the status of the lock keys -
that is, whether NumLock, ScrollLock and capsLock are on or off?

Thanks in advance

Pete



--

Dave Peterson


--

Dave Peterson
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
toggle capslock when opening workbook Otto Excel Discussion (Misc queries) 1 August 6th 08 10:37 AM
scrolllock key off whizzz2004 Excel Programming 1 April 26th 06 05:29 PM
VBA method to detect state of CAPSLOCK key? Tom Ogilvy Excel Programming 0 September 17th 04 09:17 PM
VBA method to detect state of CAPSLOCK key? Jquads Excel Programming 0 September 17th 04 08:41 PM
Sendkeys will change the status of Numlock Kenneth Lam Excel Programming 5 June 4th 04 02:05 AM


All times are GMT +1. The time now is 03:20 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"