How many keystrokes can I send per second?

Z

Zakynthos

How many keystrokes can I send per second with 'Sendkeys' statements assuming
tab keys and text are mixed?
 
G

Gary''s Student

Many, many strokes.

The keystrokes are buffered until control returns to the application, either
directly or thru DoEvents
 
G

Gary''s Student

Check back tomorrow.

I'll cook up a little macro to measure system, SendKeys about 10,000
character, and measure time again.

This will give us enough information to calculate the number of characters
per second.
 
Z

Zakynthos

Great - many thanks for your help. I'm trying to convince people at work
that lots of time will be sent in a data transfer project from one database
to another and this information will prove useful to support my arguments -
I'm also running timed tests of my program against manual input but don't
have the knowledge to time the max. keystroke output in seconds.
 
G

Gary''s Student

It is important to remember that a human is very limited in the ability to
type quickly. The standard QWERTY keyboard was designed to slow down typing,
not speed it up.

Even if you just hold a key down, the thruput is limited by the repeat rate.

We will see if SendKeys can do better!
 
G

Gary''s Student

First the code:

Private Declare Function GetTickCount Lib "Kernel32" () As Long
Sub qwerty()
Dim ary(1 To 1350) As String
Dim n1 As Long, n2 As Long
For i = 1 To 1350
ary(i) = Chr(Int(((90 - 65 + 1) * Rnd) + 65))
Next
Application.ScreenUpdating = False
Range("B9").Select
ActiveCell.Clear
n1 = GetTickCount()
Application.SendKeys "{F2}"
For i = 1 To 1350
Application.SendKeys ary(i)
Next
Application.SendKeys "{ENTER}"
DoEvents
Application.ScreenUpdating = True
n2 = GetTickCount()
MsgBox (n2 - n1)
End Sub

So we make a long array of characters, record time, pump the characters into
a cell, re-record the time, and display the difference.

On my elderly Dell, I am able to get 1350 characters into a cell in about
950 milliseconds. And thats sending them one character at a time.
 
Z

Zakynthos

Gary's student,

This is fantastic!- will use this to check my computer - the stats will hel
reinforce my arguments for more extensive automation at work - your help has
been invaluable.

Best wishes,

Tony
 
G

Gary''s Student

Glad to help!
--
Gary''s Student - gsnu200813


Zakynthos said:
Gary's student,

This is fantastic!- will use this to check my computer - the stats will hel
reinforce my arguments for more extensive automation at work - your help has
been invaluable.

Best wishes,

Tony
 
Z

Zakynthos

Tried the code but it errored:

Compile error: "Only comments may appear after End Sub, End Function or End
Property.

Where am I going wrong?

Many thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top