-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame_GTL.ahk
154 lines (123 loc) · 4.58 KB
/
Game_GTL.ahk
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#Include <_COMMON_SETTINGS_>
Menu, Tray, Icon
Reload_AsAdmin()
SendMode, Event ; нужен Event режим, т.к. только в этом режиме можно задать задержки для клавиш
SetKeyDelay, 50, 25 ; чтобы работало в играх, нужно использовать задержки при нажатиях (only Event mode)
SetMouseDelay, 50 ; Sets the delay that will occur after each mouse movement or click.
SetDefaultMouseSpeed, 0 ; Sets the mouse speed that will be used if unspecified in Click and MouseMove/Click/Drag.
GroupAdd, GTL, ahk_exe GTL.exe
JoyNumber = 2
JoyPrefix = %JoyNumber%Joy
JoyMultiplier = 0.2 ; Mouse cursor speed.
JoyThreshold = 5 ; Dead zone for RStick. A perfect joystick could use a value of 1.
MouseWheelNumber = 8 ; How many lines will be scrolled.
MouseWheelDelay = 25 ; Delay during sequential sending Mouse Wheel keys.
; Calculate the axis displacements that are needed to start moving the mouse cursor:
JoyThresholdUpper := 50 + JoyThreshold ; 50 - is a center, Min-Max = 0-100
JoyThresholdLower := 50 - JoyThreshold
Hotkey, IfWinNotActive, ahk_group GTL
Hotkey, F1, Help
Hotkey, IfWinNotExist, ahk_group GTL
Hotkey, %JoyPrefix%8, LaunchGTL
Hotkey, IfWinActive, ahk_group GTL
Hotkey, %JoyPrefix%4, Y
Hotkey, %JoyPrefix%5, LBumper
Hotkey, %JoyPrefix%6, RBumper
Hotkey, %JoyPrefix%7, Select
Hotkey, %JoyPrefix%8, Start
lX := 50 ; left "Back" icon
lY := 1015
rX := 1560 ; right "Forward" icon
rY := 900
mX := 315 ; center of menu with cars and tracks
mY := 460
#Include <JoyAxis2MouseCursor>
WatchJoystick := Func("JoyAxis2MouseCursor").Bind("V", "U", JoyMultiplier, JoyThreshold, JoyNumber)
SetTimer, %WatchJoystick%, 10
SetTimer, WatchPOV, 10
return
;==============================================================================================
;Joystick POV to Keyboard and Mouse
WatchPOV:
if WinActive("ahk_group GTL") {
GetKeyState, POV, %JoyNumber%JoyPOV ; Get position of the POV control.
KeyToSendPrev = %KeyToSend% ; Prev now holds the key that was down before (if any).
; Some joysticks might have a smooth/continuos POV rather than one in fixed increments.
; To support them all, use a range:
if POV < 0 ; No angle to report
KeyToSend =
else if POV > 31500 ; 315 to 360 degrees: Forward
KeyToSend = Up
else if POV between 0 and 4500 ; 0 to 45 degrees: Forward
KeyToSend = Up
else if POV between 4501 and 13500 ; 45 to 135 degrees: Right
KeyToSend = Right
else if POV between 13501 and 22500 ; 135 to 225 degrees: Down
KeyToSend = Down
else ; 225 to 315 degrees: Left
KeyToSend = Left
if KeyToSend = %KeyToSendPrev% ; The correct key is already down (or no key is needed).
return ; Do nothing.
if KeyToSend = Left
ClickAndMoveToMenuCenter(lX, lY) ; back
else if KeyToSend = Right
ClickAndMoveToMenuCenter(rX, rY) ; forward
else if KeyToSend = Up
Send, `` ; XD! mod - on/off
else if KeyToSend = Down
Send, e ; reset car to track
}
return
ClickAndMoveToMenuCenter(X, Y)
{
global mX, mY
Click, %X%, %Y%
MouseMove, %mX%, %mY%
}
;==============================================================================================
LaunchGTL:
Run, "E:\GAMES\GT Legends\GTL.exe", E:\GAMES\GT Legends
return
Select: ;exit race or practice
Send {Esc}{Enter} ;exit to box
Click, %lX%, %lY% ;exit to main menu
CLick, 1535, 560 ;confirm exit
MouseMove, %mX%, %mY% ;move cursor to center of left menu with cars and tracks
return
Start: ;restart
Send {Esc}{Up}{Up}{Enter}
return
Y: ;click mouse left button
Click
return
LBumper:
Loop, %MouseWheelNumber% {
Send {WheelUp}
Sleep, %MouseWheelDelay% ; I not understand why SetKeyDelay not working for this Loop :(
}
return
RBumper:
Loop, %MouseWheelNumber% {
Send {WheelDown}
Sleep, %MouseWheelDelay% ; Without this Sleep, scroll to N lines will not work
}
return
Help()
{
ShowHelpWindow("
(LTrim
Select (LButton) -> Exit race or practice.
Start (RButton) -> Restart race.
POV Left -> Click 'Back' icon in menu.
POV Right -> Click 'Forward' icon in menu.
POV Up -> XD! mod on/off.
POV Down -> Reset car to track.
RStick -> Move mouse cursor.
Y -> Click mouse LButton.
LRBumper -> Mouse wheel up and down respectively.
)")
}
;==============================================================================================
#IfWinNotActive, ahk_group GTL
!z:: Reload
!x:: ExitApp