Func _SendMessage_Click($hWnd, $BUTTON, $X, $Y, $CLICKS = 1, $delay = 15)
;$delay - пауза между 2мя нажатиями
Local $MK_LBUTTON = 0x0001
Local $WM_LBUTTONDOWN = 0x0201
Local $WM_LBUTTONUP = 0x0202
Local $MK_RBUTTON = 0x0002
;Const $WM_LBUTTONDBLCLK = 0x0203
Local $WM_RBUTTONDOWN = 0x0204
Local $WM_RBUTTONUP = 0x205
Local $WM_MOUSEMOVE = 0x200
Local $i = 0
Local $BUTTONDOWN = $WM_LBUTTONDOWN
Local $BUTTONUP = $WM_LBUTTONUP
$button = StringLower($button)
Local $user32 = DllOpen("user32.dll")
If $button = "left" Then
For $i = 1 To $CLICKS
DllCall($user32, "int", "SendMessage", "hwnd", $hWnd, "int", $WM_MOUSEMOVE, "int", 0, "long", _MAKELONG($X, $Y))
DllCall($user32, "int", "SendMessage", "hwnd", $hWnd, "int", $WM_LBUTTONDOWN, "int", $MK_LBUTTON, "long", _MAKELONG($X, $Y))
DllCall($user32, "int", "SendMessage", "hwnd", $hWnd, "int", $WM_LBUTTONUP, "int", 0, "long", _MAKELONG($X, $Y))
If $i < $CLICKS Then Sleep($delay)
Next
ElseIf $button = "right" Then
For $i = 1 To $CLICKS
DllCall($user32, "int", "SendMessage", "hwnd", $hWnd, "int", $WM_MOUSEMOVE, "int", 0, "long", _MAKELONG($X, $Y))
DllCall($user32, "int", "SendMessage", "hwnd", $hWnd, "int", $WM_RBUTTONDOWN, "int", $MK_RBUTTON, "long", _MAKELONG($X, $Y))
DllCall($user32, "int", "SendMessage", "hwnd", $hWnd, "int", $WM_RBUTTONUP, "int", 0, "long", _MAKELONG($X, $Y))
If $i < $CLICKS Then Sleep($delay)
Next
Else
SetError(-2)
If $user32 <> -1 Then DllClose($user32)
Return
EndIf
If $user32 <> -1 Then DllClose($user32)
EndFunc
Func _MakeLong($LoWord,$HiWord)
Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc