Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Can you send actual keystoke command not virtual Sendkeys

106 views
Skip to first unread message

Crowbar

unread,
Jul 3, 2009, 1:59:17 PM7/3/09
to

Hi All,

I want to be able to send actual keystokes to a application. Certain programs
can detect that I am using Sendkeys and block the strokes.

Is there anyway inwhich I can send an actual key stoke via API as though
their is an actual person present pressing the keys?

Thanks

--
Anthony Prescott
http://www.apofficesolutions.co.uk

Message posted via VBMonster.com
http://www.vbmonster.com/Uwe/Forums.aspx/vb-syntax/200904/1

Jeff Johnson

unread,
Jul 5, 2009, 3:26:08 PM7/5/09
to

"Crowbar" <u15117@uwe> wrote in message news:9887ba59f90c0@uwe...

> I want to be able to send actual keystokes to a application. Certain
> programs
> can detect that I am using Sendkeys and block the strokes.
>
> Is there anyway inwhich I can send an actual key stoke via API as though
> their is an actual person present pressing the keys?

Look up the keybd_event() API function.


Crowbar via VBMonster.com

unread,
Jul 18, 2009, 11:30:53 AM7/18/09
to
Thanks for the pointer Jeff.

I have done this and it works fine, I have put this here as an example for
anyone who is looking to do the same:

Private Declare Sub keybd_event Lib "user32.dll" (ByVal bVk As Byte, ByVal
bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)
Private Const KEYEVENTF_KEYUP = &H2
Private Const VK_LSHIFT = &HA0 ' Left SHIFT
Private Const VK_RSHIFT = &HA1 ' Right SHIFT
Private Const VK_LCONTROL = &HA2 ' Left CTRL
Private Const VK_RCONTROL = &HA3 ' Rght CTRL

Private Const VK_0 = 48
Private Const VK_1 = 49
Private Const VK_2 = 50
Private Const VK_3 = 51
Private Const VK_4 = 52
Private Const VK_5 = 53
Private Const VK_6 = 54
Private Const VK_7 = 55
Private Const VK_8 = 56
Private Const VK_9 = 57
Private Const VK_a = 65
Private Const VK_b = 66
Private Const VK_c = 67
Private Const VK_d = 68
Private Const VK_e = 69
Private Const VK_f = 70
Private Const VK_g = 71
Private Const VK_h = 72
Private Const VK_i = 73
Private Const VK_j = 74
Private Const VK_k = 75
Private Const VK_l = 76
Private Const VK_m = 77
Private Const VK_n = 78
Private Const VK_o = 79
Private Const VK_p = 80
Private Const VK_q = 81
Private Const VK_r = 82
Private Const VK_s = 83
Private Const VK_t = 84
Private Const VK_u = 85
Private Const VK_v = 86
Private Const VK_w = 87
Private Const VK_x = 88
Private Const VK_y = 89
Private Const VK_z = 90

Function PressKeys()

keybd_event VK_a, 0, 0, 0 'Press A key
keybd_event VK_b, 0, 0, 0 'Press B key
keybd_event VK_c, 0, 0, 0 'Press C key

End Function

Regards

CrowBar

Message posted via VBMonster.com
http://www.vbmonster.com/Uwe/Forums.aspx/vb-syntax/200907/1

0 new messages