Testing CapsLock Status?

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
tmallardi
Newbie
Posts: 13
Joined: Tue Jul 08, 2003 1:50 am
Location: Dallas, TX, USA

Testing CapsLock Status?

Post by tmallardi » Mon Mar 01, 2004 11:33 pm

At a certain point in one of my scripts, I need to determine the state of the CapsLock key, and proceed accordingly.

I grabbed the following VB script from the Microsoft website. However, it wil not compile. I'm really not much of a VB scripter yet though.

Can someone advise me on how I might be able to determine the state of the CapsLock key while running a Macro Scheduler script?

Thanks,
Tim

------------------------------------------------------
VBSTART

Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long)
As Integer
Const VK_NUMLOCK = &H90
Const VK_SCROLL = &H91
Const VK_CAPITAL = &H14

Key = GetKeyState(VK_CAPITAL)

If Key And 1 Then
Text3.Text = "Caps Lock is On"
Else
Text3.Text = "Caps Lock is Off"
End If
VBEND

Lumumba

Post by Lumumba » Tue Mar 02, 2004 11:16 am

Why won't this work for you ?

CapsOff
CapsOn

tmallardi
Newbie
Posts: 13
Joined: Tue Jul 08, 2003 1:50 am
Location: Dallas, TX, USA

Post by tmallardi » Tue Mar 02, 2004 9:33 pm

How easy was that!!

Obviously I didn't fully read the description of those commands.

Thanks so much.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Mar 02, 2004 10:27 pm

Why won't this work for you ?

CapsOff
CapsOn
That was also my first reaction lumumba. But then I read his question more carefully.

I thought that tmallardi wanted to know what the current status was:
I need to determine the state of the CapsLock key, and proceed accordingly
Since that status could be set by any other program, commands, user intervention, etc. it sounded like an IF command would be coming based on status of CAPS On/Off.

That's not the same as wanting to to set it to a value. Using CapsOff/On may or may not toggle the status, but if used, then the original status will be lost.

But I guess that I misunderstood the question. :oops:
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

tmallardi
Newbie
Posts: 13
Joined: Tue Jul 08, 2003 1:50 am
Location: Dallas, TX, USA

Post by tmallardi » Tue Mar 02, 2004 10:51 pm

At first I figured the CapsON & CapsOFF commands would just set the keys. When I looked closer at the commands, I realized that I could indeed accomplish my goal. All I had to do was adjust the logic a bit in my script.

Post Reply
cron
Sign up to our newsletter for free automation tips, tricks & discounts