View Single Post
Old 07-18-2008, 12:42 PM   #6
ClockWorK
Newbie
ClockWorK's CarPC Specs
 
ClockWorK's Avatar
 
Join Date: Oct 2003
Location: Michigan
Vehicle: 2004 Pontiac Grand Prix GTP CompG
Posts: 38
My Photos: ()
The keybd_event api is also good for this, if you have strings of key commands you need to pass.

Code:
'''''''' Private Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long) Private Const KEYEVENTF_EXTENDEDKEY As Long = &H1 Private Const KEYEVENTF_KEYUP As Long = &H2 Private Const VK_SHIFT As Long = &H10 Private Const VK_CONTROL As Long = &H11 Private Const VK_MENU As Long = &H12 Private Const VK_SPACE As Long = &H20 Private Const VK_PRIOR As Long = &H21 Private Const VK_NEXT As Long = &H22 Private Const VK_UP As Long = &H26 Private Const VK_DOWN As Long = &H28 Private Declare Function VkKeyScan Lib "user32" Alias "VkKeyScanA" (ByVal cChar As Byte) As Integer '''''''' Public Sub Keyboard_PressKey(ByVal key$, Optional ByVal HoldShift As Boolean = False, Optional ByVal HoldCtrl As Boolean = False, Optional ByVal HoldAlt As Boolean = False) 'this procedure uses the byte values for key presses to simulate actual keypresses. 'for now, it's only set up to handle one character at a time. Dim k As Byte On Error Resume Next Dim holdByte As Byte holdByte = CByte(Asc(key$)) k = VkKeyScan(holdByte) And &HFF If HoldShift <> False Then keybd_event VK_SHIFT, 0, KEYEVENTF_EXTENDEDKEY, 0 If HoldCtrl <> False Then keybd_event VK_CONTROL, 0, KEYEVENTF_EXTENDEDKEY, 0 If HoldAlt <> False Then keybd_event VK_MENU, 0, KEYEVENTF_EXTENDEDKEY, 0 keybd_event k, 0, KEYEVENTF_EXTENDEDKEY, 0 keybd_event k, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0 If HoldShift <> False Then keybd_event VK_SHIFT, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0 If HoldCtrl <> False Then keybd_event VK_CONTROL, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0 If HoldAlt <> False Then keybd_event VK_MENU, 0, KEYEVENTF_EXTENDEDKEY Or KEYEVENTF_KEYUP, 0 End Sub


Or, get more code: I posted a bunch at:
http://www.mp3car.com/vbulletin/soft...-attached.html
ClockWorK is offline   Reply With Quote