To use something similar to Sendkeys:
Declaration...
Public Declare Sub keybd_event Lib "coredll.dll" (ByVal bVK As Byte,
ByVal bScan As Byte, ByVal dwFlags As Integer, ByVal dwExtraInfo As
Integer)
Some useful constants...
'--- Hardware key constants and functions ---
Public Const KEYEVENTF_KEYDOWN As Integer = &H0
Public Const KEYEVENTF_KEYPRESS As Integer = &H1
Public Const KEYEVENTF_KEYUP As Integer = &H2
Public Const KEYEVENTF_SILENT As Integer = &H4
Public Const VK_LBUTTON As Integer = &H1 '---Left mouse button
Public Const VK_RBUTTON As Integer = &H2 '---Right mouse button
Public Const VK_CANCEL As Integer = &H3 '---Control-break
processing
Public Const VK_MBUTTON As Integer = &H4 '---Middle mouse button
on a three-button mouse
Public Const VK_BACK As Integer = &H8 '---BACKSPACE key
Public Const VK_TAB As Integer = &H9 '---TAB key
Public Const VK_CLEAR As Integer = &HC '---CLEAR key
Public Const VK_RETURN As Integer = &HD '---ENTER key
Public Const VK_SHIFT As Integer = &H10 '---SHIFT key
Public Const VK_CONTROL As Integer = &H11 '---CTRL key
Public Const VK_MENU As Integer = &H12 '---ALT key
Public Const VK_PAUSE As Integer = &H13 '---PAUSE key
Public Const VK_CAPITAL As Integer = &H14 '---CAPS LOCK key
Public Const VK_ESCAPE As Integer = &H1B '---ESC key
Public Const VK_SPACE As Integer = &H20 '---SPACEBAR
Public Const VK_PRIOR As Integer = &H21 '---PAGE UP key
Public Const VK_NEXT As Integer = &H22 '---PAGE DOWN key
Public Const VK_END As Integer = &H23 '---END key
Public Const VK_HOME As Integer = &H24 '---HOME key
Public Const VK_LEFT As Integer = &H25 '---LEFT ARROW key
Public Const VK_UP As Integer = &H26 '---UP ARROW key
Public Const VK_RIGHT As Integer = &H27 '---RIGHT ARROW key
Public Const VK_DOWN As Integer = &H28 '---DOWN ARROW key
Public Const VK_SELECT As Integer = &H29 '---SELECT key
Public Const VK_EXECUTE As Integer = &H2B '---EXECUTE key
Public Const VK_SNAPSHOT As Integer = &H2C '---PRINT SCREEN key
Public Const VK_INSERT As Integer = &H2D '---INS key
Public Const VK_DELETE As Integer = &H2E '---DEL key
Public Const VK_HELP As Integer = &H2F '---HELP key
Public Const VK_LWIN As Integer = &H5B '---Left Windows key on a
Microsoft Natural® keyboard
Public Const VK_RWIN As Integer = &H5C '---Right Windows key on a
Microsoft Natural keyboard
Public Const VK_APPS As Integer = &H5D '---Applications key on a
Microsoft Natural keyboard
Public Const VK_NUMPAD0 As Integer = &H60 '---Numeric keypad 0
key
Public Const VK_NUMPAD1 As Integer = &H61 '---Numeric keypad 1
key
Public Const VK_NUMPAD2 As Integer = &H62 '---Numeric keypad 2
key
Public Const VK_NUMPAD3 As Integer = &H63 '---Numeric keypad 3
key
Public Const VK_NUMPAD4 As Integer = &H64 '---Numeric keypad 4
key
Public Const VK_NUMPAD5 As Integer = &H65 '---Numeric keypad 5
key
Public Const VK_NUMPAD6 As Integer = &H66 '---Numeric keypad 6
key
Public Const VK_NUMPAD7 As Integer = &H67 '---Numeric keypad 7
key
Public Const VK_NUMPAD8 As Integer = &H68 '---Numeric keypad 8
key
Public Const VK_NUMPAD9 As Integer = &H69 '---Numeric keypad 9
key
Public Const VK_MULTIPLY As Integer = &H6A '---Multiply key
Public Const VK_ADD As Integer = &H6B '---Add key
Public Const VK_SEPARATOR As Integer = &H6C '---Separator key
Public Const VK_SUBTRACT As Integer = &H6D '---Subtract key
Public Const VK_DECIMAL As Integer = &H6E '---Decimal key
Public Const VK_DIVIDE As Integer = &H6F '---Divide key
Public Const VK_F1 As Integer = &H70 '---F1 key
Public Const VK_F2 As Integer = &H71 '---F2 key
Public Const VK_F3 As Integer = &H72 '---F3 key
Public Const VK_F4 As Integer = &H73 '---F4 key
Public Const VK_F5 As Integer = &H74 '---F5 key
Public Const VK_F6 As Integer = &H75 '---F6 key
Public Const VK_F7 As Integer = &H76 '---F7 key
Public Const VK_F8 As Integer = &H77 '---F8 key
Public Const VK_F9 As Integer = &H78 '---F9 key
Public Const VK_F10 As Integer = &H79 '---F10 key
Public Const VK_F11 As Integer = &H7A '---F11 key
Public Const VK_F12 As Integer = &H7B '---F12 key
Public Const VK_F13 As Integer = &H7C '---F13 key
Public Const VK_F14 As Integer = &H7D '---F14 key
Public Const VK_F15 As Integer = &H7E '---F15 key
Public Const VK_F16 As Integer = &H7F '---F16 key
Public Const VK_F17 As Integer = &H80 '---F17 key
Public Const VK_F18 As Integer = &H81 '---F18 key
Public Const VK_F19 As Integer = &H82 '---F19 key
Public Const VK_F20 As Integer = &H83 '---F20 key
Public Const VK_F21 As Integer = &H84 '---F21 key
Public Const VK_F22 As Integer = &H85 '---F22 key
Public Const VK_F23 As Integer = &H86 '---F23 key
Public Const VK_F24 As Integer = &H87 '---F24 key
Public Const VK_NUMLOCK As Integer = &H90 '---NUM LOCK key
Public Const VK_SCROLL As Integer = &H91 '---SCROLL LOCK key
Public Const VK_LSHIFT As Integer = &HA0 '---Left SHIFT
Public Const VK_RSHIFT As Integer = &HA1 '---Right SHIFT
Public Const VK_LCONTROL As Integer = &HA2 '---Left CTRL
Public Const VK_RONTROL As Integer = &HA3 '---Right CTRL
Public Const VK_LMENU As Integer = &HA4 '---Left ALT
Public Const VK_RMENU As Integer = &HA5 '---Right ALT
Public Const VK_ATTN As Integer = &HF6 '---ATTN key
Public Const VK_CRSEL As Integer = &HF7 '---CRSEL key
Public Const VK_EXSEL As Integer = &HF8 '---EXSEL key
Public Const VK_EREOF As Integer = &HF9 '---Erase EOF key
Public Const VK_PLAY As Integer = &HFA '---PLAY key
Public Const VK_ZOOM As Integer = &HFB '---ZOOM key
Public Const VK_NONAME As Integer = &HFC '---Reserved for future
use
Public Const VK_PA1 As Integer = &HFD '---PA1 key
Public Const VK_OEM_CLEAR As Integer = &HFE '---CLEAR key
Const VK_OFF As Integer = &HDF
Some keyboard routines:
Public Sub PowerOffSystem()
Call keybd_event(VK_OFF, 0, KEYEVENTF_KEYDOWN, 0) 'Press the
power button
Call keybd_event(VK_OFF, 0, KEYEVENTF_KEYUP, 0) 'Release
the power button
End Sub
Public Sub SendKey(ByVal cCharacter As Char)
Dim bVk As Byte
Dim bScan As Byte
Dim bUpperChar As Boolean
Dim bShiftPressed As Boolean
bUpperChar = Char.IsUpper(cCharacter)
cCharacter = Char.ToUpper(cCharacter)
bVk = CByte(AscW(cCharacter))
If ((bUpperChar And Not IsCapsLockOn()) Or (Not bUpperChar And
IsCapsLockOn()) Or Char.IsDigit(cCharacter)) Then
keybd_event(VK_SHIFT, 0, KEYEVENTF_KEYDOWN, 0)
bShiftPressed = True
End If
keybd_event(bVk, 0, KEYEVENTF_KEYDOWN, 0)
keybd_event(bVk, 0, KEYEVENTF_KEYUP, 0)
If (bShiftPressed) Then keybd_event(VK_SHIFT, 0,
KEYEVENTF_KEYUP, 0)
End Sub
Public Sub SendVirtualKey(ByVal bVk As Byte)
keybd_event(bVk, 0, KEYEVENTF_KEYDOWN, 0)
keybd_event(bVk, 0, KEYEVENTF_KEYUP, 0)
End Sub
Public Function IsCapsLockOn() As Boolean
Dim State As Short
State = GetKeyState(VK_CAPITAL)
Return (State = 1)
End Function
Hope this helps
Gianco