全局代码
Public Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As Integer)
Public Declare Function MapVirtualKey Lib "user32" Alias "MapVirtualKeyA" (ByVal wCode As Integer, ByVal wMapType As Integer) As Integer
Public Const VK_NUMLOCK = &H90 ' Num Lock
Public Const KEYEVENTF_KEYDOWN = &H0 ' KeyDown
Public Const KEYEVENTF_KEYUP = &H2 ' KeyUp
触发代码
Dim intScanCode As Integer = MapVirtualKey(VK_NUMLOCK, 0)
keybd_event(VK_NUMLOCK, intScanCode, KEYEVENTF_KEYDOWN, 0) ' 按下
keybd_event(VK_NUMLOCK, intScanCode, KEYEVENTF_KEYUP, 0) ' 放
[此贴子已经被作者于2014-7-15 15:12:13编辑过]