'API declaration for keyboard events
Extern.Declare micVoid, "keybd_event", "user32", "keybd_event", _
micbyte, micbyte, miclong, miclong
'API declaration for MapVirtualkey
Extern.Declare micVoid, "MapVirtualKey", "user32", "MapVirtualKeyA", _
micLong, micLong
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
Const KEYEVENTF_KEYDOWN = &H0
Sub KeyDown(KeyAscii)
keyCode = extern.MapVirtualKey(keyAscii, 0)
'Fire the key down event
extern.keybd_event KeyAscii, keyCode, KEYEVENTF_KEYDOWN, 0
End Sub
Sub KeyUp(KeyAscii)
keyCode = extern.MapVirtualKey(keyAscii, 0)
'Fire the key down event
extern.keybd_event KeyAscii, keyCode, KEYEVENTF_KEYUP, 0
End Sub
Sub KeyPress(KeyAscii)
KeyDown KeyAscii
KeyUp KeyAscii
End Sub
'Declare key constants here...
'simulate ALT+F
Call KeyDown(vbKeyAlt)
Call KeyDown(vbKeyF)
Call KeyUp(vbKeyF)
Call KeyUp(vbKeyAlt)
Extern.Declare micVoid, "keybd_event", "user32", "keybd_event", _
micbyte, micbyte, miclong, miclong
'API declaration for MapVirtualkey
Extern.Declare micVoid, "MapVirtualKey", "user32", "MapVirtualKeyA", _
micLong, micLong
Const KEYEVENTF_EXTENDEDKEY = &H1
Const KEYEVENTF_KEYUP = &H2
Const KEYEVENTF_KEYDOWN = &H0
Sub KeyDown(KeyAscii)
keyCode = extern.MapVirtualKey(keyAscii, 0)
'Fire the key down event
extern.keybd_event KeyAscii, keyCode, KEYEVENTF_KEYDOWN, 0
End Sub
Sub KeyUp(KeyAscii)
keyCode = extern.MapVirtualKey(keyAscii, 0)
'Fire the key down event
extern.keybd_event KeyAscii, keyCode, KEYEVENTF_KEYUP, 0
End Sub
Sub KeyPress(KeyAscii)
KeyDown KeyAscii
KeyUp KeyAscii
End Sub
'Declare key constants here...
'simulate ALT+F
Call KeyDown(vbKeyAlt)
Call KeyDown(vbKeyF)
Call KeyUp(vbKeyF)
Call KeyUp(vbKeyAlt)
No comments:
Post a Comment