• Advertisement


This topic is now archived and is closed to further replies.

Direct Input with capslocks, numlock and scroll lock(VB 6.0)

This topic is 5466 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok heres the plan just getting there is the problem... Program: I want to it be able to turn on/off the numlock, capslock, and scroll lock keys...with either a command button or just with a timer or so. Problem: i dont know where to start to look for the code or even where to begin i have tried many places, for example www.pscode.com and searched for Caplocks it gave me this code to use:''************************************** '' Name: CapsLock and NumLock '' Description:How to Activate CapsLock a '' nd NumLock from Code '' By: Ian Ippolito (RAC) '' '' Assumes:The keyboard APIs for VB4-16 a '' nd VB3 do not support the byte data type '' . By changing the Windows constant To Public Const VK_NUMLOCK = &H90, you can use the above to activate the NumLock key. '' ''This code is copyrighted and has'' limited warranties.Please see http://w '' ww.Planet-Source-Code.com/xq/ASP/txtCode '' Id.242/lngWId.1/qx/vb/scripts/ShowCode.h '' tm''for details.''************************************** On a form, add a 3 command buttons (cmdToggle, cmdTurnOff, cmdTurnOff) and a label. Add the following code to the form: Private Function CapsLock() As Integer CapsLock = GetKeyState(VK_CAPITAL) And 1 = 1 End Function Private Sub Form_Load() If CapsLock() = 1 Then Label1 = "On" Else Label1 = "Off" End Sub Private Sub cmdToggle_Click() GetKeyboardState kbArray kbArray.kbByte(VK_CAPITAL) = IIf(kbArray.kbByte(VK_CAPITAL) = 1, 0, 1) SetKeyboardState kbArray Label1 = IIf(CapsLock() = 1, "On", "Off") End Sub Private Sub cmdTurnOn_Click() GetKeyboardState kbArray kbArray.kbByte(VK_CAPITAL) = 1 SetKeyboardState kbArray Label1 = IIf(CapsLock() = 1, "On", "Off") End Sub Private Sub cmdTurnOff_Click() GetKeyboardState kbArray kbArray.kbByte(VK_CAPITAL) = 0 SetKeyboardState kbArray Label1 = IIf(CapsLock() = 1, "On", "Off") End Sub I did this exact thing and made a capslock function using the Tools | Add Procedure method it gave me an error saying "Sub or Function Not Defined" and highligted the GetKeyState function under the capslock() function and this form is my last hope also as a begginer in programing i would love for your guys advice of good sites to go to, to help out solve problems and stuff like that and learn more to go to the intermediate stage. Thanks, Yo.

Share this post

Link to post
Share on other sites

  • Advertisement