Hi everyone .
Can anyone help me how on the caps key through coding?
3 1061
Hi
Open new standard exe project. Create a command button (command1) on form1 add following code in the form's code window. - Option Explicit
-
' Declare Type for API call:
-
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 Declare Function GetKeyboardState Lib "user32" _
-
(pbKeyState As Byte) As Long
-
-
Private Declare Function SetKeyboardState Lib "user32" _
-
(lppbKeyState As Byte) As Long
-
-
' Constant declarations:
-
Const VK_NUMLOCK = &H90
-
Const VK_SCROLL = &H91
-
Const VK_CAPITAL = &H14
-
Const KEYEVENTF_EXTENDEDKEY = &H1
-
Const KEYEVENTF_KEYUP = &H2
-
Const VER_PLATFORM_WIN32_NT = 2
-
Const VER_PLATFORM_WIN32_WINDOWS = 1
-
-
Private Sub Command1_Click()
-
Dim o As OSVERSIONINFO
-
Dim NumLockState As Boolean
-
Dim ScrollLockState As Boolean
-
Dim CapsLockState As Boolean
-
-
o.dwOSVersionInfoSize = Len(o)
-
GetVersionEx o
-
Dim keys(0 To 255) As Byte
-
GetKeyboardState keys(0)
-
-
' NumLock handling:
-
NumLockState = keys(VK_NUMLOCK)
-
If NumLockState <> True Then 'Turn numlock on
-
If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then '=== Win95/98
-
-
keys(VK_NUMLOCK) = 1
-
SetKeyboardState keys(0)
-
ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then '=== WinNT
-
'Simulate Key Press
-
keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
-
'Simulate Key Release
-
keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY _
-
Or KEYEVENTF_KEYUP, 0
-
End If
-
End If
-
-
' CapsLock handling:
-
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 If
-
-
' ScrollLock handling:
-
ScrollLockState = keys(VK_SCROLL)
-
If ScrollLockState <> True Then 'Turn Scroll lock on
-
If o.dwPlatformId = VER_PLATFORM_WIN32_WINDOWS Then '=== Win95/98
-
keys(VK_SCROLL) = 1
-
SetKeyboardState keys(0)
-
ElseIf o.dwPlatformId = VER_PLATFORM_WIN32_NT Then '=== WinNT
-
'Simulate Key Press
-
keybd_event VK_SCROLL, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0
-
'Simulate Key Release
-
keybd_event VK_SCROLL, &H45, KEYEVENTF_EXTENDEDKEY _
-
Or KEYEVENTF_KEYUP, 0
-
End If
-
End If
-
End Sub
Regards
manpreet singh dhillon hoshiarpur
Thanks, Manpreet. But it might help if chandru8 could tell us what the actual question is.
Thanks, Manpreet
thanks for your kindly help
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Robert |
last post by:
Hi!
I was wondering if the was any way to determine the state of the caps
lock key, on or off.
Of course I can capture the key events and see whether the caps lock is
pressed, but that does not...
|
by: Peter D |
last post by:
I have a second hand bar code reader (keyboard wedge) en i can read
the bar codes but after every scan he turns my caps lock on.
(GRRRRRR).
I search a code to turn my caps lock off or can anyone...
|
by: Malcolm |
last post by:
Use all lower case for ansi c functions, and Capitalise For
Platform-Specific.
If you call something with caps, then your function name requires caps
itself.
|
by: Mike L |
last post by:
How do I turn Caps Lock on, when my form opens?
|
by: John A Grandy |
last post by:
does anyone know of an intrinsic .NET function , or font , or other
mechanism , to do "proper-case all-caps" ... ?
so, for a name like "Arnold Schwarzenegger" ...
.... I want it entirely in...
|
by: charlies224 |
last post by:
Hi,
I am writting a software that requires me to make sure the Num Lock is
always on and Caps Lock is always off.
First, I know how to detect if Num Lock or Caps Lock is on or off (if...
|
by: sengmca |
last post by:
hi friends,
this is senny, here i have to solve my pbm thrugh ur kind suggestion.In my project ,i have to restrict the user to use "CAPS KEY" like when we go to login if caps pressed the msbbox is...
|
by: Fred's |
last post by:
Hi Folks,
I've been trying to figure out how can I see the text in caps in my
report, but til now, nothing works.
Does anyone knows how can I makes the text in caps in my report?
Your...
|
by: trondhuso |
last post by:
Hi,
I have a solution that - at time of writing - has to use tables to
render a list of database-results. My challenge though is that we have
used iframes and such to render the different lists...
|
by: DanicaDear |
last post by:
I want to use all caps in a database. I desire to show all caps AS YOU TYPE regardless of how the keyboard/caps lock is set. I tried to format my form field with an on-click event…and this is the...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |