HCI: Button clicking
Written by Indiana   
Wednesday, 07 July 2004
ImageClicking on one and the same pixel everytime easily reveals automated play. But is the human behaviour modeled better if the computer bot is randomly clicking on the button? The answer is - no. When a human clicks, the distance from the click to the center of the button follows normal distribution, and not uniform.
So how should this work?
Let say you want to click on a button, where the coordinates of the button center are (x, y) and the distances from the center to the edges of the button are rx and ry. The Java function that does that is:

public void clickButton(int x, int y, int rx, int ry, int delay) {
int rx2 = (int) (randomNormalScaled(2*rx, 0, 1) - (rx));
int ry2 = (int) (randomNormalScaled(2*ry, 0, 1) - (ry));
clickMouseAt(x + rx2, y + ry2, delay);

Here is the full working code (simple standalone Java class) that also contains more detailed explanation of the routines:


Last Updated ( Saturday, 08 September 2007 )