|
-
Jun 11th, 2000, 10:42 AM
#1
Thread Starter
Hyperactive Member
I know this should be pretty damn easy. I need to know how to turn on the Cap key through the code. I know I should use setkeyboardstate but I just don't know the rest of the command for this API.
-
Jun 11th, 2000, 07:15 PM
#2
Lively Member
I don't know the API call for this, but you could cheat by using the following
On the form, turn on the keypreview property at design time
in form_keypress enter the following code
private sub Form_Keypress(KeyAscii as Integer)
keyascii=asc(ucase(chr(keyascii)))
end sub
This will make sure that every letter pressed is in upper case and means that if the user turns off the caps lock when you don't want them to it doesn't matter
All this does is converts the keyascii value (ASCII value of the key) to the charector (Chr(KeyAscii)), converts this to uppercase (Ucase(chr(keyAscii))) and converts it back to as ASCII code (asc(ucase(chr(keyAscii)))
All the keypreview property does is makes sure that the forms key events are processed before the controls key events
Hope this helps
Chris
-
Jun 11th, 2000, 07:38 PM
#3
You can try this
This code is supposed to do it, but it was not working right for me.
Code:
SendKeys "{capslock}"
Hope this works for ya
-
Jun 11th, 2000, 07:59 PM
#4
_______
another way
'vb6
'capitalize all small case letters
'
If Chr(KeyAscii) >= "a" And Chr(KeyAscii) <= "z" Then
KeyAscii = KeyAscii - 32
End If
'
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Jun 11th, 2000, 08:01 PM
#5
Hyperactive Member
API
here's a routine I use which is originally based upon a KPD Team example :
Code:
Option Explicit
Const KB_CAPITAL = &H14
Private Type Key_Bytes
KeyState(0 To 255) As Byte
End Type
Private Declare Function GetKeyboardState Lib "user32" (Key_Array As Key_Bytes) As Long
Private Declare Function SetKeyboardState Lib "user32" (Key_Array As Key_Bytes) As Long
Dim Key_Array As Key_Bytes
Private Sub Main()
CapsOn
CapsOff
End Sub
Private Sub CapsOn()
GetKeyboardState Key_Array
Key_Array.KeyState(KB_CAPITAL) = 1
SetKeyboardState Key_Array
End Sub
Private Sub CapsOff()
GetKeyboardState Key_Array
Key_Array.KeyState(KB_CAPITAL) = 0
SetKeyboardState Key_Array
End Sub
That's Mr Mullet to you, you mulletless wonder.
-
Jun 12th, 2000, 12:19 PM
#6
Hyperactive Member
Paul,
How about the NumLock key, what is the constant value?
-
Jun 12th, 2000, 03:03 PM
#7
Hyperactive Member
More values
The ones that I can find are :
Const KB_CAPITAL = &H14
Const KB_NUMLOCK = &H90
Const KB_SCROLL = &H91
Hope this helps.
That's Mr Mullet to you, you mulletless wonder.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|