Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1976
  • Last Modified:

VK_NUMLOCK and it's values

Ok, nice easy one for you VB guru's I am starting into VB and find the best way to lean is to read code as well as books, anyway I came across some code that had the constants as shown below.

I understand that the VK_NUMLOCK = &H90 is equivalent to VK_NUMLOCK = 144 and this is the value associated to the Num Lock key but I am not sure what the  value does within the code, i.e. does it set Num Lock to on?

Const VK_NUMLOCK = &H90
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2

Further into the code is the following line:

keybd_event VK_NUMLOCK, &H45, KEYEVENTF_EXTENDEDKEY Or 0, 0

I understand that this changes the value but again to what?

It would be great if somebody could give me an explanation of what the other two values are:

EXTENDEDKEY and KEYUP

and is there a link that gives a full list of the &H1 values and the keys they are associated with.
0
trojan_uk
Asked:
trojan_uk
  • 2
2 Solutions
 
vinnyd79Commented:
The constant will press the NUMLOCK key down,then you have to use KEYUP to release it.For example:

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 Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Const KEYEVENTF_KEYUP = &H2
Const VK_NUMLOCK = &H90
Const KEYEVENTF_EXTENDEDKEY = &H1


Private Sub Command1_Click()
    keybd_event VK_NUMLOCK, 0, 0, 0 ' Press NUMLOCK key down
    keybd_event VK_NUMLOCK, 0, KEYEVENTF_KEYUP, 0 ' Release it
End Sub
0
 
JohnBPriceCommented:
EXTENDED KEY indicates the keystroke you want to send is from an extended key on the keyboard.  Some keys do not have ASCII equivalents, for these the keyboard sends two bytes instead of one for the VK_ code, EXTENDED KEY simulates the 0xE0 (224) prefix that some keys on the keyboard generate.
0
 
trojan_ukAuthor Commented:
Thanks guys
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now