-
Notifications
You must be signed in to change notification settings - Fork 1
/
ClickerHeroes_functions.au3
66 lines (55 loc) · 1.8 KB
/
ClickerHeroes_functions.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
; 1) Check if the previous HWND is valid
; 1.1) if not, look for the Clicker Heroes Window
; 1.2) return Status
; >> automatically sets $CH_Hwnd
Func CH_exists()
if $CH_Hwnd == 0 or IsHWnd($CH_Hwnd) == 0 then
resetMousePos() ; reset the settings of the previous window
local $hwnd_temp = WinGetHandle("Clicker Heroes")
if $hwnd_temp == 0 then
$CH_Hwnd = 0
return 0
else
$CH_Hwnd = $hwnd_temp
return $CH_Hwnd
endif
else
return IsHWnd($CH_Hwnd)
endif
endfunc
Func doInactivityClick()
if CH_exists() then
_PostMessage_FastClick($CH_Hwnd, $MousePosX, $MousePosY, $User32, 1, 10)
$inactivityClickTimer = 0
else
$inactivityClickTimer = -10 ; ClickerHeroes isn't opened, next check in 19s
endif
endfunc
Func calcMouseCoords_winapi()
local $clientSize = WinGetClientSize($CH_Hwnd)
Local $mousePos = MouseGetPos() ; 0 = X; 1 = Y
Local $mousePosStruct = DllStructCreate("int X;int Y")
DllStructSetData($mousePosStruct, "X", $mousePos[0])
DllStructSetData($mousePosStruct, "Y", $mousePos[1])
local $rtvalue = _WinAPI_ScreenToClient($CH_Hwnd, $mousePosStruct)
local $newCoords[2] = [DllStructGetData($mousePosStruct, "X"), DllStructGetData($mousePosStruct, "Y")]
if $newCoords[0] < 1 or $newCoords[1] < 1 or $newCoords[0] > $clientSize[0] or $newCoords[1] > $clientSize[1] then
; Mouse is outside the CH Window
return $defaultMousePos
else
; Mouse is inside the window, the calculations are correct
return $newCoords
endif
endfunc
Func setCurrentMousePos()
$mouseClickerPos = calcMouseCoords_winapi()
$MousePosX = $mouseClickerPos[0]
$MousePosY = $mouseClickerPos[1]
endfunc
; reset mousePos to default
; > Used when the previous window was closed
Func resetMousePos()
$mouseClickerPos = $defaultMousePos
$MousePosX = $defaultMousePos[0]
$MousePosY = $defaultMousePos[1]
endfunc