i got a small question :) is there a way to show if caps are on or off in a text box ? i used the search but i coulndt find a thing :( im just wondering if theres a way...like the box below(the vbcode is: on box) i need that,but then for caps :)
Printable View
i got a small question :) is there a way to show if caps are on or off in a text box ? i used the search but i coulndt find a thing :( im just wondering if theres a way...like the box below(the vbcode is: on box) i need that,but then for caps :)
I think you can do it, would be an API call to find out if caps are on or off!
Then just display in a textbox. Never tried
isnt there a way without a api..?
got some code i could work from :(?
I declare myself n00B
Here is an explanation of how to do it. I dont think you can without an API.
http://www.mentalis.org/apilist/GetKeyState.shtml
You could use the keypress event and check if the ascii value is in the "caps" range.
Quote:
Originally Posted by Neo-dark
Look on your machine for a program called APIloader.exe (Think I spelled it right).
I think you would have to use the API!
I have lots of API code but nothing like this.
:blush:
It is APILOAD.exe
now i found it ! :lol: :eek2: :rolleyes: ;) heheh :afrog:
so what should i look for now ? :rolleyes: :p this is hard :(
i tried typing in'capital' and CAPS but found nothing on both :'( it would be the same effect for scrl lock and such right ? imma look for it again on the search
To load it you must first click File then load text.
Then pick win32api.txt
i did that :P it dint find anything bout caps,like i said before im looking for code now i found some but where should i place this..?
Code:Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
Private Const VK_CAPITAL = &H14
Private Const VK_NUMLOCK = &H90
Private Const VK_SCROLL = &H91
ReDim KeyboardBuffer(256) As Byte
GetKeyboardState KeyboardBuffer(0)
'This example show you how to press the Caps Lock button. if you want
'to press the Num Lock button, Replace all the following 3 'VK_CAPITAL'
'with 'VK_NUMLOCK' or VK_SCROLL as desired.
If KeyboardBuffer(VK_CAPITAL) And 1 Then
KeyboardBuffer(VK_CAPITAL) = 0
Else
KeyboardBuffer(VK_CAPITAL) = 1
End If
SetKeyboardState KeyboardBuffer(0)
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
'To check if Num Lock is on Replace the 'vbKeyCapital' below with 'vbKeyNumlock'
Dim lngWhatState As Long
lngWhatState = GetKeyState(vbKeyCapital)
If lngWhatState = 1 Then
MsgBox "The Caps Lock Is On"
Else
MsgBox "The Caps Lock Is Off"
End If
Declare Function GetKeyboardState Lib "user32" Alias "GetKeyboardState" (pbKeyState As Byte) As Long
That what I found all so! Do not know how it work google "GetKeyboardState"
and see what you find
coulnd find nothing big im trying it ou on a form i hope it works...
nope wont function i tried putting it in a module,class,ect but it works in nothing..?:( i dunno where to place itttt :'(
i am such a n00b
You must declare it like this
This at the top of a form.Code:Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Then in form load I call it.
Code:If GetUserName(strUserName_Form_Load, Len(strUserName_Form_Load)) = 0 Then
MsgBox "Unable to get user ID. Program terminating", , "PBDT120 - ERROR"
Unload Me
Else
strUserID_Form_Load = Left$(strUserName_Form_Load, InStr(strUserName_Form_Load, Chr$(0)) - 1)
End If
Its keeps giving me the line"compile error: invalid outside call procedure"
really thanks allot for helping me find it out :) this is my code right now:
Code:Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
Private Const VK_CAPITAL = &H14
Private Const VK_NUMLOCK = &H90
Private Const VK_SCROLL = &H91
ReDim KeyboardBuffer(256) As Byte
GetKeyboardState KeyboardBuffer(0)
'This example show you how to press the Caps Lock button. if you want
'to press the Num Lock button, Replace all the following 3 'VK_CAPITAL'
'with 'VK_NUMLOCK' or VK_SCROLL as desired.
If KeyboardBuffer(VK_CAPITAL) And 1 Then
KeyboardBuffer(VK_CAPITAL) = 0
Else
KeyboardBuffer(VK_CAPITAL) = 1
End If
SetKeyboardState KeyboardBuffer(0)
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
'To check if Num Lock is on Replace the 'vbKeyCapital' below with 'vbKeyNumlock'
Dim lngWhatState As Long
lngWhatState = GetKeyState(vbKeyCapital)
If lngWhatState = 1 Then
MsgBox "The Caps Lock Is On"
Else
MsgBox "The Caps Lock Is Off"
End If
Private Sub Form_Load()
If GetUserName(strUserName_Form_Load, Len(strUserName_Form_Load)) = 0 Then
MsgBox "Unable to get user ID. Program terminating", , "PBDT120 - ERROR"
Unload Me
Else
strUserID_Form_Load = Left$(strUserName_Form_Load, InStr(strUserName_Form_Load, Chr$(0)) - 1)
End If
End Sub
Try this.
Code:Option Explicit
Private Type KeyboardBytes
kbByte(0 To 255) As Byte
End Type
Private Declare Function GetKeyboardState Lib "user32" (kbArray As KeyboardBytes) As Long
Private Const VK_CAPITAL = &H14
Private Const VK_NUMLOCK = &H90
Private Const VK_SCROLL = &H91
Private Sub Text1_GotFocus()
Dim KeyboardBuffer As KeyboardBytes
GetKeyboardState KeyboardBuffer
If KeyboardBuffer.kbByte(VK_CAPITAL) = 0 Then
MsgBox "Caps off"
Else
MsgBox "Caps on"
End If
End Sub
Option Explicit
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Private Declare Function GetKeyboardState Lib "user32" (pbKeyState As Byte) As Long
Private Declare Function SetKeyboardState Lib "user32" (lppbKeyState As Byte) As Long
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
Private Const VK_CAPITAL = &H14
Private Const VK_NUMLOCK = &H90
Private Const VK_SCROLL = &H91
ReDim KeyboardBuffer(256) As Byte
GetKeyboardState KeyboardBuffer(0)
'This example show you how to press the Caps Lock button. if you want
'to press the Num Lock button, Replace all the following 3 'VK_CAPITAL'
'with 'VK_NUMLOCK' or VK_SCROLL as desired.
If KeyboardBuffer(VK_CAPITAL) And 1 Then
KeyboardBuffer(VK_CAPITAL) = 0
Else
KeyboardBuffer(VK_CAPITAL) = 1
End If
SetKeyboardState KeyboardBuffer(0)
Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer
'To check if Num Lock is on Replace the 'vbKeyCapital' below with 'vbKeyNumlock'
Dim lngWhatState As Long
lngWhatState = GetKeyState(vbKeyCapital)
If lngWhatState = 1 Then
MsgBox "The Caps Lock Is On"
Else
MsgBox "The Caps Lock Is Off"
End If
Private Sub Form_Load()
Call lngWhatState
If GetUserName(strUserName_Form_Load, Len(strUserName_Form_Load)) = 0 Then
MsgBox "Unable to get user ID. Program terminating", , "PBDT120 - ERROR"
Unload Me
Else
strUserID_Form_Load = Left$(strUserName_Form_Load, InStr(strUserName_Form_Load, Chr$(0)) - 1)
End If
End Sub
This might work I moved " Private Declare Function GetKeyState Lib "user32" (ByVal nVirtKey As Long) As Integer" and call the funtion in form load
:wave:
Marty, his code looks better
marti,mudfish,i have 2 new gods
[]bows[]it works now :) thanks allot :> im so happy now :p i cant thank you enough :>
Glad we could help. Now please help us by editing the first post and adding the green checkmark.Quote:
Originally Posted by Neo-dark
TADAAAA :P done it :) so much of my post are left un-awnsered..i guess i always ask hard questions ?:P