- ©«¤l
- 519
- ¥DÃD
- 54
- ºëµØ
- 0
- ¿n¤À
- 595
- ÂI¦W
- 255
- §@·~¨t²Î
- win 10
- ³nÅ骩¥»
- []
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- µù¥U®É¶¡
- 2013-3-19
- ³Ì«áµn¿ý
- 2024-11-22
|
¦^´_ 6# jackyq
¦^´_ 3# PKKO
·íµM sendkeys «Ü§@©Ç
¥¦¤£¶È¼vÅT numlock, capslock, scroll, ÁÙ·|²ö¦W¨ä§®¶]¥X©w¸q¦WºÙ°Ñ·Óþ¤@Ó¦ì¸m!!
#3¼Ó ´£¨ì https://support.microsoft.com/zh-tw/kb/179987
³o¥÷¤å¥óªº¸Ñ¨M¤è®×¦³3¡A «e2Ó¸Õ¤F³£¤£¦æ
¦A¸Õ²Ä3ӫܨ±°jªº¤è®×¦p¤U¡A¦n¹³¥i¥Héwªº¸Ñ¨M°ÝÃD (win10)
Option Explicit
' API declarations:
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_KEYUP = &H2
'https://support.microsoft.com/zh-tw/kb/179987
'Resolution:
'Determine the setting of the NumLock key prior to using SendKeys.
'Then, turn off the NumLock before using SendKeys.
'After using SendKeys,reset the NumLock to its previous setting.
'This is accomplished using the GetKeyboardState, keybd_event and SetKeyboardState API functions.
'================================================================================================
Private Sub test() '´ú¸Õ sendkeys
presetNumlock
SendKeys "^g^a{DEL}" ', True
TurnNumlock
End Sub
Sub presetNumlock()
Dim bKeys(0 To 255) As Byte
Dim LockState%
'Get status of the 256 virtual keys
GetKeyboardState bKeys(0)
'turn off the num_lock key
If bKeys(vbKeyNumlock) = 1 Then
TurnNumlock
End If
DoEvents '¤@©wn ?
End Sub
Sub TurnNumlock()
'Simulate Key Press
keybd_event vbKeyNumlock, 1, 0, 0
'Simulate Key Release
keybd_event vbKeyNumlock, 1, KEYEVENTF_KEYUP, 0
End Sub |
|