Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm simulating a double click programmatically and I want to have a slight pause between both clicks in order to better simulate a real user.

I know the interval should be less than GetDoubleClickTime but am not sure what would be a good time to choose. Does anyone know of any data on how fast a typical person performs a double-click?

I was thinking in the direction GetDoubleClickTime()/3 but of course the magic number seems a bit iffy.

share|improve this question
Why not just say GetDoubleClickTime() - 1? Unless the simulation is specific to the exact double click length a double click is just another input. – Josh K Nov 9 '11 at 15:20
@JoshK sleeping is not always precise, if I oversleep by one millisecond I will get two clicks rather than one double click. – Motti Nov 9 '11 at 15:24
Doesn't the hardware/operating system determine the difference between a single click and a double click? So as long as you send two clicks within the threshold for what is considered a double click, it doesn't matter. You just need to simulate "a user sent a double click", not all the various timing differences that might be considered a double click. – Thomas Owens Nov 9 '11 at 15:44
up vote 2 down vote accepted

Does anyone know of any data on how fast a typical person performs a double-click? - doubleclick interval is an adjustable OS user setting.

Our user might not have configured his machine typically.

I don't know what's the issue with GetDoubleClickTime() / 3. Even if there was some research proving that an average person doubleclicks 2.56768 time faster than the required minimum speed - 2.56768 is still a magic number of sorts...

share|improve this answer

Fire up an audio recording program in a quiet space and double click your mouse a few times. The time distance between the two peaks is how long it takes. If you're feeling really intense, you can calculate the statistical deviation among many clicks.

Me? I'd go with your thought of GetDoubleClickTime()/3. I think you're over-analyzing a double click.

share|improve this answer

You could do something really fancy, like:

(GetDoubleClickTime() * 2 / 3) + (rand(0, (GetDoubleClickTime() / 2)) - (GetDoubleClickTime() / 4))

But I kinda agree with Jeff. Since catching double clicks is an OS task; and it just comes back to your program as "the user double clicked at (x, y)" I think you might be over-working this a bit.

The simplest way to simulate clicks is to call the handler directly.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.