For $i = 1 To 10
$iTimer = TimerInit()
_MouseClickEx('primary', Random(0, @DesktopWidth, 1), Random(0, @DesktopHeight, 1))
;_MouseClickEx()
ConsoleWrite(StringFormat('%.2f ms', TimerDiff($iTimer)) & @LF)
Next
Func _MouseClickEx($s_Button = 'primary', $i_X = Default, $i_Y = Default, $i_Clicks = 1, $i_SpeedMin = 1, $i_SpeedMax = 10, $i_DownMin = 20, $i_DownMax = 50)
Local $i_OptOld, $i_Opt, $i_OptOld_1, $i_Opt_1, $i_Speed, $i_Ret
If Not StringInStr('|left|right|middle|main|menu|primary|secondary|', '|' & $s_Button & '|') Then
$s_Button = 'primary'
EndIf
$i_Clicks = Abs(Int($i_Clicks))
$i_SpeedMin = Abs(Int($i_SpeedMin))
$i_SpeedMax = Abs(Int($i_SpeedMax))
If $i_SpeedMin >= $i_SpeedMax Then
$i_Speed = 0
Else
$i_Speed = Random($i_SpeedMin, $i_SpeedMax, 1)
EndIf
$i_DownMin = Abs(Int($i_DownMin))
$i_DownMax = Abs(Int($i_DownMax))
If $i_DownMin >= $i_DownMax Then
$i_Opt = 10
Else
$i_Opt = Random($i_DownMin, $i_DownMax, 1)
EndIf
If $i_Clicks > 1 Then
$i_Opt_1 = $i_Opt + Random(1, 10, 1)
$i_OptOld_1 = Opt('MouseClickDelay', $i_Opt_1)
EndIf
$i_OptOld = Opt('MouseClickDownDelay', $i_Opt)
$i_Ret = MouseClick($s_Button, $i_X, $i_Y, $i_Clicks, $i_Speed)
Opt('MouseClickDownDelay', $i_OptOld)
If $i_Clicks > 1 Then
Opt('MouseClickDelay', $i_OptOld_1)
EndIf
Return $i_Ret
EndFunc ;==>_MouseClickEx