Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Turning Scroll, Num And Caps Lock On/off Through Code


Hi All,
another quick question.... Is there a WORKING way of turning the Scroll, Num and Caps lock keys on and off through code? I have tried using send keys but that doesn't do anything. I need it to turn the associated light on or off.

Thanx again,

-Scott




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Detect Num Lock Caps Lock And Scroll Lock <solved>
i am creating a small password username program and the password is case sensitive and i want it to be but i want to warn the user if the caps lock or num lock or scroll lock is on, though i do not know to detect if these are on , anyone know thanks!.

Best Reguards


Dave Barr

Edited by - crazyoldman on 1/11/2006 11:38:51 AM

Num Lock, Scroll Lock && Caps Lock QUestion
How can i activate the Num Lock, Scroll Lock & Caps Lock using vb?

State Of CAPS, Num, And Scroll Lock
Sorry to resurrect this old post, but it is directly relevant to what I want.

I use Passel's method to get the keystates:

Code:
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Const KEY_TOGGLED As Integer = &H1

Private Sub Timer1_Timer()
If (GetKeyState(vbKeyCapital) And KEY_TOGGLED) Then Debug.Print "Caps Lock on"
End Sub

The trouble is that this only works when my program (or VB's IDE) has focus. If it does not have the focus then a change in the CAPS LOCK state isn't recognised.

I'm making a program which displays the current CAPS, NUM & SCROLL lock states in the system tray (like some cordless keyboards do) so I don't want to have a window hanging around all the time. How could I make this work 100% of the time without having a window visible to give focus to?

Thanks

State Of CAPS, Num, And Scroll Lock
How would you check if the CAPS, Num, and Scroll Locks were on?
Thanks

Controlling Caps, Num, And Scroll Lock.
Can anyone tell me how to control my num, caps, and scroll lock through visual basic. i want to switch them on and off.

------------------

Lock Shift/Caps Lock Keys
Does anybody know how to temporarily disable the use of the shift and caps lock keys to change case?
And how to detect the status of the caps lock?

Shift Lock Or Caps Lock Key Control
Is it possible to control the Shift Lock key whenever a field got the focus.

I want the user to type capital letters even if the Shift Lock or Caps lock key isn't presed.

I can after the typing use UCASE(field) but want to show the capitals immeditate on my form.

Caps Lock - On Or Off?
I'll go straight to my problem.

I have form with label1 added to it. When I start my application or whenever I press Caps Lock I want label1 to show the following.

"caps lock = on" <- when caps lock is on

"caps lock = off" <- when caps lock is off

I have searched the forum but I can only find commands and functions that will trigger caps lock either on or off.

Please guide me right

How Do I Tell If Caps Lock Is On Or Off?
how do i tell if caps lock is on or off?

by the way im using dx7 input to detect keypresses...
but i dont mind if i dont have to use dx7

Caps Lock On!!!!
Two queires:

1- What it is the code to know if CAPS LOCK is ON???

2- How to know IF user pressed Enter KEY ?

Thanks

Caps Lock
how to detect caps lock and num lock?

Caps Lock
Hi,

How to enable caps locks in my app. so that caps is always on in my app. and that the user cannot turn it off.

Caps Lock
Why does this code only affect the caps lock setting inside the program?
The LED on the keyboard doesn't change at all and when I type in another program, the caps lock setting is the same as before I ran this code!

Please tell me how to fix this!
Btw, I'm using Win2k...


VB Code:
Option ExplicitPrivate Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As LongPrivate Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long Dim bKeys(255) As Byte Private Sub Form_Click()    Dim i As Long        GetKeyboardState bKeys(0)        If bKeys(20) = 0 Then        bKeys(20) = 1    ElseIf bKeys(20) = 1 Then        bKeys(20) = 0    End If        SetKeyboardState bKeys(0)End Sub

Caps Lock Is On/off
I need to detect whether caps lock and Num lock is on/off in the form load event.?

Caps Lock On??
How can I determine if the caps lock button is on or off

Is Caps Lock On?
I got a (hopefully) quck question.

Does anybody know how I can tell if caps lock, scroll lock, or number lock is on? I don't want to know how to toggle them. I just want to be able to tell if it's on or not.

How To On The CAPS Lock
please tell me how to write the coding to on the caps lock as the
cursor moves to the text box

example if i have three text box in a from , from where i'll be getting values for EMPNAME, EMPCODE,SALARY

I want the caps lock to be on when the cursor is in the text box where i am accepting EMPNAME


PLEEZ HELP
MY EMAIL ID is sajisurendran@rediffmail.com

CAPS LOCK
Help!

How can I force a CAPS LOCK. I assume it'll be something to do with Get/SetKeyState. The app I'm working on is being ported from VB3 where it used the KeySta16 control. NT won't let me register this control and so I'm stuck without a way of forcing caps lock.

I have tried the code from VB-Square (posted by Sam Hugill) but it appears to be lacking a function...

Caps Lock On
Hi all



How can I switch on the caps lock so that whether or not the user switchd
it on, whatever is typed in text boxes is always in CAPITALS. I donot wat
to check the key pressed at the event. Any help, please.





Rajiv Kumar

How To Set The Caps Lock On In VB6?
hi!

i would like to know, or if this is possible, how to set the caps lock on every time i run the form?
i have a textbox and i wanted all inputs in capital letter,how do i do that in vb6?

thanks



Edited by - say2x on 10/21/2005 2:19:48 AM

Caps Lock
is there a way to see if the Caps Lock is on?

if so, is there a way to set it on or off?

Caps Lock
How can I disable the use of the caps lock and the shift keys in a text box keypress event
I need to be able to control how the user inputs text in a text box by code

Set Caps Lock On
Hi
I wanna set the Caps Lock on when a field is on focus. Thanx.

Caps Lock Etc
Is there a way for my vb5 app to know whether the CapsLock is on or off, not just whether it's been pressed. Same for NumLock and ScrollLock. Thanks

Voice Recognition, Microphones, and Text-To-Speech.
Products, Support, and International Sales.
www.talking.co.uk

CAPS LOCK Button Help
I asked this question awhile back, and i never did get a straight answer, so i thought i'd try again. I would like to have my application turn the Caps lock button to ON when my application gets focus, then to turn it off when it losses focus. Is this possible? Yes i know i could put in lots of validation code to not accept lowercase letters in all my text boxes or i could use lots of lines of code to Ucase everything, but I don't want to go down that road if i dont' have too. I'm assuming that all i'd have to do is use my forms Focus events to do this, but i dont' know how to check the status of the Capslock key. Any help would be appreciated.

Disabling Caps Lock
Does anybody know how to disable caps lock in 9X/NT/2K/ME in such a way that it can't be turned on until I re-enable it, but I can still use the Shift key to get capital letters?

Thanks.

Caps Lock Status
How would I work out if Caps lock is on?

Force CAPS Lock On
How can I set CAPS lock on throughout entire program?

Toggle Caps Lock
Does anyone know how to toggle the caps lock key (using a timer)? (Perferably no API funtions)

[Access] Caps Lock
I would like to be able to programatically set Caps Lock on or off,
depending on which field a user is in while using a data entry form.

Would this be possible?

Forcing CAPS LOCK Off
For my application I need to turn the CAPS LOCK off.
To do this I use the following code in VB6:
Private Declare Function GetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Private Declare Function SetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long

'
TurnOff VK_CAPITAL 'VK_CAPITAL=&H14
'

Private Sub TurnOff(vkKey As Long)
'Get the keyboard state
GetKeyboardState kbArray
'change a key
kbArray.kbByte(vkKey) = 0
'set the keyboard state
SetKeyboardState kbArray
End Sub

This function comes from the API guide and works nice on
my WIN95 and WIN98 system.
However it turns out not to work on 2 WIN XP PRO systems.

Should it work ? or is another routine needed ?
thanks in advance for any help.

RAW

Disabeling The CAPS Lock
Hi all.. I'm in a bit of a jam..Can some one provide me with some sample code to disable the CAPS lock?

Thank you..

Rudy

CAPS LOCK Warning
Hi

I am looking at putting a 'CAPS LOCKED' bubble on our login screen but just wondered if this something I need to code of it there is some sort of dialog that will do it for me

Anyone any ideas?

Cheers

Switch On/off Caps Lock
Hello Experts,
I am expected to switch on/off caps lock key.
can any help me.Thanx in advance.

How Can I Turn On Caps Lock?
I'm trying to do this, I got a code but sounds like it doesnt work for windows NT. What is a SIMPLE way to do this? I tried SendKeys function too, but for some reason it didn't work
help needed!!!!

Thanks in advance

CAPS Lock Just Curious
Why when i use the following code (taken from msdn) - In Windows 2000 I have to press two times on Caps Lock to Disable Caps.

VB Code:
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As LongPrivate Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As LongConst VK_CAPITAL = &H14Const VER_PLATFORM_WIN32_NT = 2Const VER_PLATFORM_WIN32_WINDOWS = 1       Private Type OSVERSIONINFO        dwOSVersionInfoSize As Long        dwMajorVersion As Long        dwMinorVersion As Long        dwBuildNumber As Long        dwPlatformId As Long        szCSDVersion As String * 128   '  Maintenance string for PSS usage      End Type       ' API declarations:       Private Declare Function GetVersionEx Lib "kernel32" _         Alias "GetVersionExA" _         (lpVersionInformation As OSVERSIONINFO) As Long       Private Declare Sub keybd_event Lib "user32" _         (ByVal bVk As Byte, _          ByVal bScan As Byte, _          ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Private Sub Form_Load() lblVersion.Caption = "Ver. " & App.Major & "." & App.Minor & "." & App.RevisionDim CapsLockState As BooleanDim o As OSVERSIONINFO       o.dwOSVersionInfoSize = Len(o)      GetVersionEx o      Dim keys(0 To 255) As Byte      GetKeyboardState keys(0) CapsLockState = keys(VK_CAPITAL)      If CapsLockState <> True Then    'Turn capslock on        If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then  '=== Win95/98          keys(VK_CAPITAL) = 1          SetKeyboardState keys(0)        ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then   '=== WinNT        'Simulate Key Press          keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0        'Simulate Key Release          keybd_event VK_CAPITAL, &H45, KEYEVENTF_EXTENDEDKEY _             Or KEYEVENTF_KEYUP, 0        End If      End IfEnd Sub

Detect Caps Lock
My project is using web application. After all the codes i tried, it is still not working. Can anybodi help me? To detect caps lock on and prompt user. The codes i have are not working. which i'm not sure whether is it because it is only for window application or wat?


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        While CapsLockOn() = True
            Image1.Visible = True
        End While

    End Sub

    Dim dbm As New DBmethods
    Const VK_CAPITAL = &H14

    Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

    Public Function CapsLockOn() As Boolean
        Dim iKeyState As Integer
        iKeyState = GetKeyState(VK_CAPITAL)
        CapsLockOn = (iKeyState = 1 Or iKeyState = -127)
    End Function

God bless
Winnie

How To Find Whether Caps Lock Is On Or Not :)
i would like to know how to detect whether the Caps Lock key is on or off.. using visual basic codes.. can someone provide me with the code please. thankin u in advance



Edited by - ibrahim@naeem on 5/23/2004 12:56:09 PM

Detect Caps Lock
may i know whether is this applicable for web form?

i have the following codes..
but there is a line undernealth
Code:vbKeyCapital
can anyone help me.

Option Explicit
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer

Public Function CapsLockOn() As Boolean
    Dim iKeyState As Integer
    iKeyState = GetKeyState(vbKeyCapital)
    CapsLockOn = (iKeyState = 1 Or iKeyState = -127)
End Function
Private Sub cmdIsCapsOn_Click()
    If CapsLockOn = True Then
        MsgBox "Yes, Capslock is on!"
    Else
        MsgBox "No, Capslock is NOT on!"
    End If
End Sub


 

Automatic Caps Lock Switching... HOW?
Is there anyway in which i can activate the caps lock through vb?

Thanks

The X3M

Sending Caps Lock... [never Mind]
one more quick question, is it possible to enable caps lock when a control gets focus and disable it when the control loses focus? will sendkeys toggle caps lock? is there an option to turn it ON or OFF as opposed to just changing the state? how do i represent caps lock with sendkeys? thanks!

don't worry about this. i changed my approach.



Edited by - dave_h8z_ms on 7/29/2004 9:23:42 AM

Enable The Caps Lock Key When Program Is In Focus....
How hard would it be to have the Caps Lock key turned on when my program has focus, then to disable it when my program loses focus? I use my program for my data entry job, and all data entered must be in CAPS. Thanks in advance
Edit:
I know i could just save use the Ucase() command to convert everything to CAPS before it gets sent to the server, but i'd like to avoid this if i can.

--Joey

Enable Caps Lock Key At Form Load
Hi!
am using VB 6

i want the caps lock key to be on enabled during at form load.

can anyone tell me what is the code for it?

it would very much appreciated..
thank you!

Caps Lock-num Lock
Hello,
I have seen that some programs (like messaging applications) notify the user of new messages using a flash of the keyboard lights (Caps lock, scroll lock, etc). I'm guessing that you would need to do this via API, but I am not sure whether you would actually need to turn on/off Caps Lock, or just use an API to make the keyboard switch on/off the light.

I would be greatful for any help.

Caps Lock/Num Lock On Or Off?
Hi,
Is there any simple way to check if Num lock/Caps lock is on or off?

Show Tooltips Text Directly When Caps Lock Is On
hello everyone,

just like my thread title... i would like to display the tooltips text directly or automatically when the caps lock is on, regardless the mouse pointer location.

any idea or example can share to me?

thanks

CAPS Lock AutoOn For Specific Active Window
does anybody have an idea how i get a program working which is activating CAPSLock if a specific window is in the foregourd (active) and deactivate caps lock if that window is minimized or set to the background by the user...

Scroll Lock
Does anybody know what functions Scroll Lock has in general computing?

_-_-KiCkInIt-_-_

"**** the torpedoes, full speed ahead!!!"

Scroll Lock?
is there a way in vb to determine if the scroll lock is on?
you know that throw back key that somehow still exists but no one uses? i actually have a legitimate "scroll locking" use for it now and I'm not sure how to check to see if it's on

Copyright 2005-08 www.BigResource.com, All rights reserved