This repository has been archived by the owner on Aug 15, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MouseClickPlus.au3
66 lines (57 loc) · 2.47 KB
/
MouseClickPlus.au3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include-once
#include <SendMessage.au3>
; #FUNCTION# ====================================================================================================================
; Name ..........: _MouseClickPlus
; Description ...: Sends a click to window.
; Syntax ........: _MouseClickPlus($hWnd[, $sButton = 'left' [, $vX [, $vY [, $iClicks = 1]]]])
; Parameters ....: $hWnd - A window handle to send click(s) to
; $sButton - [optional] 'left' (default) or 'right'
; $vX - [optional] X coordinate
; $vY - [optional] Y coordinate
; $iClicks - [optional] Number of clicks to send. Default is 1.
; Return values .: None
; Author ........: Insolence <[email protected]>
; Modified ......: Walkman
; Remarks .......: You MUST be in "MouseCoordMode" 0 to use this without bugs.
; Not entirely accurate, but works minimized.
; Related .......: _SendMessage, DllCall, MouseGetPos
; Link ..........: http://www.autoitscript.com/forum/topic/7112-minimized-clicking-great-for-game-bots/page__hl__Insolence
; Example .......: No
; ===============================================================================================================================
Func _MouseClickPlus($hWnd, $vX = '', $vY = '', $sButton = 'left', $iClicks = 1)
Local $MK_LBUTTON = 0x0001
Local $WM_LBUTTONDOWN = 0x0201
Local $WM_LBUTTONUP = 0x0202
Local $MK_RBUTTON = 0x0002
Local $WM_RBUTTONDOWN = 0x0204
Local $WM_RBUTTONUP = 0x0205
Local $WM_MOUSEMOVE = 0x0200
If $sButton = 'left' Then
$Button = $MK_LBUTTON
$ButtonDown = $WM_LBUTTONDOWN
$ButtonUp = $WM_LBUTTONUP
ElseIf $sButton = 'right' Then
$Button = $MK_RBUTTON
$ButtonDown = $WM_RBUTTONDOWN
$ButtonUp = $WM_RBUTTONUP
EndIf
If $vX = "" Or $vY = "" Then
$MouseCoord = MouseGetPos()
$vX = $MouseCoord[0]
$vY = $MouseCoord[1]
EndIf
;~ Local $stPoint = DllStructCreate('long;long')
Local $stPoint = _MakeLong($vX, $vY)
;~ DllStructSetData($stPoint, 1, $vX)
;~ DllStructSetData($stPoint, 2, $vY)
;~ ConsoleWrite('$stPoint: ' & $stPoint & ' _Makelong(): ' & _Makelong($vX, $vY) & @CR)
Local $i = 0
For $i = 1 To $iClicks
_SendMessage($hWnd, $WM_MOUSEMOVE, 0, $stPoint)
_SendMessage($hWnd, $ButtonDown, $Button, $stPoint)
_SendMessage($hWnd, $ButtonUp, $Button, $stPoint)
Next
EndFunc ;==>_MouseClickPlus2
Func _MakeLong($LoWord,$HiWord)
Return BitOR($HiWord * 0x10000, BitAND($LoWord, 0xFFFF))
EndFunc