├── .gitattributes ├── PanAmerican1 V0.4 - PS4.AHK ├── PanAmerican1 V0.5.AHK ├── PanAmerican1 V0.5.exe ├── README.md ├── SpecialTrackXAFK Tom.ahk └── python_scripts ├── README.md └── race_in_circles.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /PanAmerican1 V0.4 - PS4.AHK: -------------------------------------------------------------------------------- 1 | #NoEnv 2 | #MaxHotkeysPerInterval 99000000 3 | #HotkeyInterval 99000000 4 | #KeyHistory 0 5 | ListLines Off 6 | Process, Priority, , A 7 | SetBatchLines, -1 8 | SetKeyDelay, -1, -1 9 | SetMouseDelay, -1 10 | SetDefaultMouseSpeed, 0 11 | SendMode Input ; Recommended for new scripts due to its superior speed and reliability. 12 | 13 | SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. 14 | DetectHiddenWindows, On 15 | #Persistent 16 | 17 | 18 | 19 | ; --------- Controls 20 | accel := "Enter" 21 | turnLeft := "Left" 22 | turnRight := "Right" 23 | brake := "Up" 24 | nitros := "Down" 25 | 26 | ; --------- Constants 27 | ; Time at turn in seconds and Stablizing control 28 | t := 225000 29 | intensity := 220 30 | delay := 140 31 | color_check := 0x3E1858 32 | 33 | ; ---------- Gui Setup ------------- 34 | Gui, -MaximizeBox 35 | Gui, 2: -MaximizeBox 36 | Gui, 2: -MinimizeBox 37 | Gui, Color, c282a36, c6272a4 38 | Gui, Add, Button, x15 y10 w70 default, Start 39 | Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables 40 | Gui, Add, Button, x15 y70 w70 default gGetColo, ColorP 41 | Gui, Font, ce8dfe3 s9 w550 Bold 42 | 43 | ;--------- Gui 2 Setup -------------- 44 | Gui, 2: Color, c535770, c6272a4 45 | Gui, 2: Font, c11f s9 Bold 46 | Gui, 2: Add, Text,, Turn Length (time miliseconds) 47 | Gui, 2: Add, Edit, w70 vA, %t% 48 | Gui, 2: Add, Text,, Turn Intensity 49 | Gui, 2: Add, Edit, w40 vB, %intensity% 50 | Gui, 2: Add, Text,, Turn Delay 51 | Gui, 2: Add, Edit, w40 vC, %delay% 52 | 53 | 54 | Gui, 2: Add, Button, x20 y170 gSaveVars, Save 55 | Gui, 2: Add, Button, x100 y170 gVarDef, Defaults 56 | Gui, Show,w220 h120, GT7 Pan American AFK 57 | return 58 | 59 | VariableWindow: 60 | Gui, 2: Show, w220 h205, Variables 61 | return 62 | 63 | SaveVars: 64 | Gui, 2:Submit 65 | GuiControlGet, t, 2:, A 66 | GuiControlGet, intensity, 2:, B 67 | GuiControlGet, delay, 2:, C 68 | return 69 | 70 | VarDef: 71 | t = 262000 72 | intensity = 220 73 | delay := 140 74 | GuiControl, 2:, A, %t% 75 | GuiControl, 2:, B, %intensity% 76 | GuiControl, 2:, C, %delay% 77 | return 78 | 79 | ButtonStart: 80 | Gui, Submit, NoHide 81 | id := "" 82 | SetKeyDelay, 10 83 | Process, priority, , High 84 | gosub, GrabRemotePlay 85 | if (id = "") 86 | return 87 | gosub, PauseLoop 88 | CoordMode, Pixel, Screen 89 | CoordMode, ToolTip, Screen 90 | sleep 1000 91 | gosub, AFKLoop 92 | ; ---------- Gui Setup End------------- 93 | 94 | 95 | AFKLoop: 96 | loop{ 97 | ;gosub, Menu 98 | gosub, PressX 99 | DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version 100 | gosub, Race 101 | gosub, Menu 102 | } 103 | return 104 | 105 | PressX: 106 | ; Just for menuing, does not hold X down 107 | ControlSend,, {%accel% down}, ahk_id %id% 108 | DllCall("Sleep", "UInt", 200) 109 | ControlSend,, {%accel% up}, ahk_id %id% 110 | return 111 | 112 | PressRight: 113 | ; For turning 114 | ControlSend,, {%turnRight% down}, ahk_id %id% 115 | Sleep, 50 116 | ControlSend,, {%turnRight% up}, ahk_id %id% 117 | return 118 | 119 | ; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for 120 | TurnRight: 121 | t0 := A_TickCount 122 | tf := t0+t 123 | 124 | loop { 125 | ControlSend,, {%turnRight% down}, ahk_id %id% 126 | DllCall("Sleep", "UInt", intensity) 127 | ControlSend,, {%turnRight% up}, ahk_id %id% 128 | DllCall("Sleep", "UInt", delay) 129 | } until A_TickCount > tf 130 | return 131 | 132 | 133 | TurnLeft: 134 | t0 := A_TickCount 135 | tf := t0+t 136 | 137 | loop { 138 | ControlSend,, {%turnLeft% down}, ahk_id %id% 139 | DllCall("Sleep", "UInt", intensity) 140 | ControlSend,, {%turnLeft% up}, ahk_id %id% 141 | 142 | DllCall("Sleep", "UInt", delay) 143 | } until A_TickCount > tf 144 | return 145 | 146 | 147 | Race: 148 | ; Hold Acceleration and manage turning 149 | ControlSend,, {%accel% down}, ahk_id %id% 150 | ControlSend,, {%nitros% down}, ahk_id %id% 151 | DllCall("Sleep", "UInt", 2000) 152 | gosub TurnRight 153 | /* 154 | ; This section detects the end of the race. Can be used to be faster/more accurate at the ending but good timing takes less computer resources 155 | Screen: 218, 359 (less often used) 156 | Window: 222, 357 (default) 157 | Client: 214, 326 (recommended) 158 | Color: 3F1757 (Red=3F Green=17 Blue=57) 159 | */ 160 | loop { 161 | PixelSearch, x, y, 216, 357, 220, 361, %color_check%, 20, Fast RGB 162 | If (ErrorLevel != 0) { 163 | ControlSend,, {%turnRight% down}, ahk_id %id% 164 | Sleep, 140 165 | ControlSend,, {%turnRight% up}, ahk_id %id% 166 | Sleep, 200 167 | } 168 | else{ 169 | break 170 | } 171 | 172 | 173 | } 174 | 175 | ControlSend,, {%accel% up}, ahk_id %id% 176 | ControlSend,, {%nitros% up}, ahk_id %id% 177 | return 178 | 179 | 180 | 181 | Menu: 182 | ; Screen: 342, 363 (less often used) 183 | ; Window: 342, 363 (default) 184 | ; Client: 342, 363 (recommended) 185 | ; Color: 48A267 (Red=48 Green=A2 Blue=67) 186 | loop { 187 | PixelSearch, x, y, 340, 361, 344, 365, 0x48A267, 20, Fast RGB 188 | If (ErrorLevel != 0) { 189 | gosub, PressX 190 | sleep 300 191 | } 192 | else{ 193 | break 194 | } 195 | } 196 | Sleep, 2000 197 | ControlSend,, {Right down}, ahk_id %id% 198 | Sleep, 200 199 | ControlSend,, {Right up}, ahk_id %id% 200 | Sleep, 500 201 | gosub, PressX 202 | Sleep, 25000 ;ps4 lag time 1 203 | gosub, PressX 204 | Sleep, 1000 205 | ControlSend,, {Esc down}, ahk_id %id% 206 | Sleep, 200 207 | ControlSend,, {Esc up}, ahk_id %id% 208 | loop, 2 { 209 | gosub, PressX 210 | Sleep, 500 211 | } 212 | Sleep, 9000 ;ps4 lag time 2 213 | ControlSend,, {Down down}, ahk_id %id% 214 | Sleep, 200 215 | ControlSend,, {Down up}, ahk_id %id% 216 | Sleep, 500 217 | loop, 6 { 218 | ControlSend,, {Right down}, ahk_id %id% 219 | Sleep, 200 220 | ControlSend,, {Right up}, ahk_id %id% 221 | Sleep, 200 222 | } 223 | loop, 2{ 224 | gosub, PressX 225 | Sleep, 1200 226 | } 227 | Sleep, 18000 ;ps4 lag time 3 228 | loop, 2{ 229 | ;ToolTip, %A_Index% X, 100, 100 230 | gosub, PressX 231 | Sleep, 1000 232 | } 233 | return 234 | 235 | 236 | ;; General Functions for AHK 237 | 238 | GrabRemotePlay: 239 | WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe 240 | if (remotePlay_id = 0) 241 | { 242 | MsgBox, PS4 Remote Play not found 243 | return 244 | } 245 | Loop, %remotePlay_id% 246 | { 247 | id := remotePlay_id%A_Index% 248 | WinGetTitle, title, % "ahk_id " id 249 | If InStr(title, "PS Remote Play") 250 | break 251 | } 252 | WinGetClass, remotePlay_class, ahk_id %id% 253 | WinMove, ahk_id %id%,, 0, 0, 640, 360 254 | ControlFocus,, ahk_class %remotePlay_class% 255 | WinActivate, ahk_id %id% 256 | return 257 | 258 | RPwind: 259 | WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe 260 | if (remotePlay_id = 0) 261 | { 262 | MsgBox, PS4 Remote Play not found 263 | return 264 | } 265 | Loop, %remotePlay_id% 266 | { 267 | id := remotePlay_id%A_Index% 268 | WinGetTitle, title, % "ahk_id " id 269 | If InStr(title, "PS Remote Play") 270 | break 271 | } 272 | WinGetClass, remotePlay_class, ahk_id %id% 273 | WinMove, ahk_id %id%,, -700, -400, 640, 360 274 | ControlFocus,, ahk_class %remotePlay_class% 275 | WinActivate, ahk_id %id% 276 | return 277 | 278 | PixelColorSimple(pc_x, pc_y) 279 | { 280 | WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe 281 | if (remotePlay_id = 0) 282 | { 283 | MsgBox, PS4 Remote Play not found 284 | return 285 | } 286 | if remotePlay_id 287 | { 288 | pc_wID := remotePlay_id[0] 289 | pc_hDC := DllCall("GetDC", "UInt", pc_wID) 290 | pc_fmtI := A_FormatInteger 291 | SetFormat, IntegerFast, Hex 292 | pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt") 293 | pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16 294 | pc_c .= "" 295 | SetFormat, IntegerFast, %pc_fmtI% 296 | DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC) 297 | return pc_c 298 | 299 | } 300 | } 301 | 302 | 303 | Distance(c1, c2) 304 | { ; function by [VxE], return value range = [0, 441.67295593006372] 305 | return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2)) 306 | } 307 | 308 | GetColo: 309 | ;Screen: 218, 359 (less often used) 310 | tmp := PixelColorSimple(218, 359) 311 | ; testing here to try and get background window colors, can't figure it out 312 | ;col_distance := Distance(tmp, color_check) 313 | ;if (col_distance < 5) 314 | ; MsgBox, good 315 | ;else 316 | ; MsgBox, wahh %tmp% 317 | ;return 318 | MsgBox, set color_check to %tmp% 319 | return 320 | 321 | PauseLoop: 322 | ControlSend,, {%accel% up}, ahk_id %id% 323 | ControlSend,, {%nitros% up}, ahk_id %id% 324 | ControlSend,, {%turnLeft% up}, ahk_id %id% 325 | ControlSend,, {%turnRight% up}, ahk_id %id% 326 | return 327 | 328 | GuiClose: 329 | gosub, PauseLoop 330 | ExitApp 331 | 332 | ^Esc::ExitApp -------------------------------------------------------------------------------- /PanAmerican1 V0.5.AHK: -------------------------------------------------------------------------------- 1 | #NoEnv 2 | #MaxHotkeysPerInterval 99000000 3 | #HotkeyInterval 99000000 4 | #KeyHistory 0 5 | ListLines Off 6 | Process, Priority, , A 7 | SetBatchLines, -1 8 | SetKeyDelay, -1, -1 9 | SetMouseDelay, -1 10 | SetDefaultMouseSpeed, 0 11 | SendMode Input ; Recommended for new scripts due to its superior speed and reliability. 12 | 13 | SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. 14 | DetectHiddenWindows, On 15 | #Persistent 16 | 17 | 18 | 19 | ; --------- Controls 20 | accel := "Enter" 21 | turnLeft := "Left" 22 | turnRight := "Right" 23 | brake := "Up" 24 | nitros := "Down" 25 | 26 | ; --------- Constants 27 | ; Time at turn in seconds and Stablizing control 28 | t := 220000 29 | intensity := 220 30 | delay := 160 31 | 32 | color_check1 := 0x3E1858 33 | color_check2 := 0x48A267 34 | c1_alt := false 35 | 36 | ; ---------- Gui Setup ------------- 37 | Gui, -MaximizeBox 38 | Gui, 2: -MaximizeBox 39 | Gui, 2: -MinimizeBox 40 | Gui, Color, c282a36, c6272a4 41 | Gui, Add, Button, x15 y10 w70 default, Start 42 | Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables 43 | Gui, Add, Button, x15 y70 w70 default gGetColo_p, ColorP1 44 | Gui, Add, Button, x110 y70 w70 default gGetColo_g, ColorP2 45 | Gui, Font, ce8dfe3 s9 w550 Bold 46 | 47 | ;--------- Gui 2 Setup -------------- 48 | Gui, 2: Color, c535770, c6272a4 49 | Gui, 2: Font, c11f s9 Bold 50 | Gui, 2: Add, Text,, Turn Length (time miliseconds) 51 | Gui, 2: Add, Edit, w70 vA, %t% 52 | Gui, 2: Add, Text,, Turn Intensity 53 | Gui, 2: Add, Edit, w40 vB, %intensity% 54 | Gui, 2: Add, Text,, Turn Delay 55 | Gui, 2: Add, Edit, w40 vC, %delay% 56 | 57 | 58 | Gui, 2: Add, Button, x20 y170 gSaveVars, Save 59 | Gui, 2: Add, Button, x100 y170 gVarDef, Defaults 60 | Gui, Show,w220 h120, GT7 Pan American AFK 61 | return 62 | 63 | VariableWindow: 64 | Gui, 2: Show, w220 h205, Variables 65 | return 66 | 67 | SaveVars: 68 | Gui, 2:Submit 69 | GuiControlGet, t, 2:, A 70 | GuiControlGet, intensity, 2:, B 71 | GuiControlGet, delay, 2:, C 72 | return 73 | 74 | VarDef: 75 | t = 220000 76 | intensity = 220 77 | delay := 140 78 | GuiControl, 2:, A, %t% 79 | GuiControl, 2:, B, %intensity% 80 | GuiControl, 2:, C, %delay% 81 | return 82 | 83 | ButtonStart: 84 | Gui, Submit, NoHide 85 | id := "" 86 | SetKeyDelay, 10 87 | Process, priority, , High 88 | gosub, GrabRemotePlay 89 | if (id = "") 90 | return 91 | gosub, PauseLoop 92 | CoordMode, Pixel, Screen 93 | CoordMode, ToolTip, Screen 94 | sleep 1000 95 | gosub, AFKLoop 96 | ; ---------- Gui Setup End------------- 97 | 98 | 99 | AFKLoop: 100 | loop{ 101 | ;gosub, Menu 102 | gosub, PressX 103 | DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version 104 | gosub, Race 105 | gosub, Menu 106 | } 107 | return 108 | 109 | PressX: 110 | ; Just for menuing, does not hold X down 111 | ControlSend,, {%accel% down}, ahk_id %id% 112 | DllCall("Sleep", "UInt", 200) 113 | ControlSend,, {%accel% up}, ahk_id %id% 114 | return 115 | 116 | PressRight: 117 | ; For turning 118 | ControlSend,, {%turnRight% down}, ahk_id %id% 119 | Sleep, 50 120 | ControlSend,, {%turnRight% up}, ahk_id %id% 121 | return 122 | 123 | ; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for 124 | TurnRight: 125 | t0 := A_TickCount 126 | tf := t0+t 127 | 128 | loop { 129 | ControlSend,, {%turnRight% down}, ahk_id %id% 130 | DllCall("Sleep", "UInt", intensity) 131 | ControlSend,, {%turnRight% up}, ahk_id %id% 132 | DllCall("Sleep", "UInt", delay) 133 | } until A_TickCount > tf 134 | return 135 | 136 | 137 | TurnLeft: 138 | t0 := A_TickCount 139 | tf := t0+t 140 | 141 | loop { 142 | ControlSend,, {%turnLeft% down}, ahk_id %id% 143 | DllCall("Sleep", "UInt", intensity) 144 | ControlSend,, {%turnLeft% up}, ahk_id %id% 145 | 146 | DllCall("Sleep", "UInt", delay) 147 | } until A_TickCount > tf 148 | return 149 | 150 | 151 | Race: 152 | ; Hold Acceleration and manage turning 153 | 154 | ControlSend,, {%accel% down}, ahk_id %id% 155 | ControlSend,, {%nitros% down}, ahk_id %id% 156 | DllCall("Sleep", "UInt", 8200) 157 | gosub TurnRight 158 | /* 159 | ; This section detects the end of the race. Can be used to be faster/more accurate at the ending but good timing takes less computer resources 160 | Screen: 218, 359 (less often used) 161 | Window: 222, 357 (default) 162 | Client: 214, 326 (recommended) 163 | Color: 3F1757 (Red=3F Green=17 Blue=57) 164 | */ 165 | loop { 166 | PixelSearch, x, y, 216, 357, 220, 361, %color_check1%, 20, Fast RGB 167 | If (ErrorLevel != 0) { 168 | ControlSend,, {%turnRight% down}, ahk_id %id% 169 | Sleep, 140 170 | ControlSend,, {%turnRight% up}, ahk_id %id% 171 | Sleep, 200 172 | } 173 | else{ 174 | /* haven't gotten this to work, for color picking when pixel search acting dumb 175 | if (c1_alt ) { 176 | loop, 10{ 177 | gosub, PressX 178 | Sleep, 2000 179 | } 180 | } 181 | While c1_alt 182 | Sleep 1000 183 | */ 184 | break 185 | } 186 | 187 | 188 | } 189 | 190 | ControlSend,, {%accel% up}, ahk_id %id% 191 | ControlSend,, {%nitros% up}, ahk_id %id% 192 | return 193 | 194 | 195 | 196 | Menu: 197 | loop { 198 | PixelSearch, x, y, 340, 361, 344, 365, %color_check2%, 20, Fast RGB 199 | If (ErrorLevel != 0) { 200 | gosub, PressX 201 | sleep 300 202 | } 203 | else{ 204 | break 205 | } 206 | } 207 | Sleep, 2000 208 | ControlSend,, {Esc down}, ahk_id %id% 209 | Sleep, 200 210 | ControlSend,, {Esc up}, ahk_id %id% 211 | Sleep, 200 212 | ControlSend,, {Right down}, ahk_id %id% 213 | Sleep, 200 214 | ControlSend,, {Right up}, ahk_id %id% 215 | Sleep, 500 216 | gosub, PressX 217 | Sleep, 14000 218 | gosub, PressX 219 | Sleep, 1000 220 | ControlSend,, {Esc down}, ahk_id %id% 221 | Sleep, 200 222 | ControlSend,, {Esc up}, ahk_id %id% 223 | loop, 2 { 224 | gosub, PressX 225 | Sleep, 500 226 | } 227 | Sleep, 7000 228 | ControlSend,, {Down down}, ahk_id %id% 229 | Sleep, 200 230 | ControlSend,, {Down up}, ahk_id %id% 231 | Sleep, 500 232 | loop, 6 { 233 | ControlSend,, {Right down}, ahk_id %id% 234 | Sleep, 200 235 | ControlSend,, {Right up}, ahk_id %id% 236 | Sleep, 200 237 | } 238 | loop, 2{ 239 | gosub, PressX 240 | Sleep, 1200 241 | } 242 | Sleep, 8400 243 | loop, 2{ 244 | gosub, PressX 245 | Sleep, 1000 246 | } 247 | return 248 | 249 | 250 | ;; General Functions for AHK 251 | 252 | GrabRemotePlay: 253 | WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe 254 | if (remotePlay_id = 0) 255 | { 256 | MsgBox, PS4 Remote Play not found 257 | return 258 | } 259 | Loop, %remotePlay_id% 260 | { 261 | id := remotePlay_id%A_Index% 262 | WinGetTitle, title, % "ahk_id " id 263 | If InStr(title, "PS Remote Play") 264 | break 265 | } 266 | WinGetClass, remotePlay_class, ahk_id %id% 267 | WinMove, ahk_id %id%,, 0, 0, 640, 360 268 | ControlFocus,, ahk_class %remotePlay_class% 269 | WinActivate, ahk_id %id% 270 | return 271 | 272 | RPwind: 273 | WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe 274 | if (remotePlay_id = 0) 275 | { 276 | MsgBox, PS4 Remote Play not found 277 | return 278 | } 279 | Loop, %remotePlay_id% 280 | { 281 | id := remotePlay_id%A_Index% 282 | WinGetTitle, title, % "ahk_id " id 283 | If InStr(title, "PS Remote Play") 284 | break 285 | } 286 | WinGetClass, remotePlay_class, ahk_id %id% 287 | WinMove, ahk_id %id%,, -700, -400, 640, 360 288 | ControlFocus,, ahk_class %remotePlay_class% 289 | WinActivate, ahk_id %id% 290 | return 291 | 292 | PixelColorSimple(pc_x, pc_y) 293 | { 294 | WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe 295 | if (remotePlay_id = 0) 296 | { 297 | MsgBox, PS4 Remote Play not found 298 | return 299 | } 300 | if remotePlay_id 301 | { 302 | pc_wID := remotePlay_id[0] 303 | pc_hDC := DllCall("GetDC", "UInt", pc_wID) 304 | pc_fmtI := A_FormatInteger 305 | SetFormat, IntegerFast, Hex 306 | pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt") 307 | pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16 308 | pc_c .= "" 309 | SetFormat, IntegerFast, %pc_fmtI% 310 | DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC) 311 | return pc_c 312 | 313 | } 314 | } 315 | 316 | 317 | Distance(c1, c2) 318 | { ; function by [VxE], return value range = [0, 441.67295593006372] 319 | return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2)) 320 | } 321 | 322 | GetColo_p: 323 | ;Screen: 218, 359 (less often used) 324 | color_check1 := PixelColorSimple(218, 359) 325 | ;MsgBox, At the screen with [Replay] [Next Race], Press ColorP2 326 | c1_alt := true 327 | 328 | return 329 | 330 | GetColo_g: 331 | ;Screen: 218, 359 (less often used) 332 | color_check2 := PixelColorSimple(343, 363) 333 | c1_alt := false 334 | return 335 | 336 | PauseLoop: 337 | ControlSend,, {%accel% up}, ahk_id %id% 338 | ControlSend,, {%nitros% up}, ahk_id %id% 339 | ControlSend,, {%turnLeft% up}, ahk_id %id% 340 | ControlSend,, {%turnRight% up}, ahk_id %id% 341 | return 342 | 343 | GuiClose: 344 | gosub, PauseLoop 345 | ExitApp 346 | 347 | ^Esc::ExitApp -------------------------------------------------------------------------------- /PanAmerican1 V0.5.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ByPrinciple/GT7-Scripts/ec68b3688e6aa5231bfed29cbf14068033d1489e/PanAmerican1 V0.5.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GT7 Scripts 2 | Autohotkey scripts for GT7 to farm creddits 3 | -------------------------------------------------------------------------------- /SpecialTrackXAFK Tom.ahk: -------------------------------------------------------------------------------- 1 | DetectHiddenWindows, On 2 | #Persistent 3 | #NoEnv 4 | 5 | /* 6 | ==================== Script Notes ======================= 7 | = = 8 | = Script for farming credits in GT7 = 9 | = Using the course Special Stage Route X = 10 | = Set control scheme to directional button steering = 11 | = Set X to accelerate = 12 | = = 13 | = Have game ready with "Start" button before the race = 14 | = Press start on the script = 15 | = = 16 | ==================================================== 17 | */ 18 | ; --------- Controls 19 | accel := "Enter" 20 | turnLeft := "Left" 21 | turnRight := "Right" 22 | 23 | ; --------- Constants 24 | ; Time at turn in seconds and Stablizing control 25 | FTEnt = 85 26 | FTExi = 110 27 | STEnt = 205 28 | STExi = 248 29 | BO = 200 30 | FTS = 400 31 | STS = 401 32 | 33 | script = 1 34 | ; ---------- Gui Setup ------------- 35 | Gui, -MaximizeBox 36 | Gui, -MinimizeBox 37 | Gui, 2: -MaximizeBox 38 | Gui, 2: -MinimizeBox 39 | Gui, Color, c282a36, c6272a4 40 | Gui, Add, Button, x15 y10 w70 default, Start 41 | Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables 42 | Gui, Font, ce8dfe3 s9 w550 Bold 43 | 44 | 45 | ;--------- Gui 2 Setup -------------- 46 | Gui, 2: Color, c535770, c6272a4 47 | Gui, 2: Font, c11f s9 Bold 48 | Gui, 2: Add, Text,, First Turn Enter 49 | Gui, 2: Add, Edit, w40 vA, %FTEnt% 50 | Gui, 2: Add, Text,, First Turn Exit 51 | Gui, 2: Add, Edit, w40 vB, %FTExi% 52 | Gui, 2: Add, Text,, Second Turn Enter 53 | Gui, 2: Add, Edit, w40 vC, %STEnt% 54 | Gui, 2: Add, Text,, Second Turn Exit 55 | Gui, 2: Add, Edit, w40 vD, %STExi% 56 | Gui, 2: Add, Text, x125 y0, Beginning Overtake 57 | Gui, 2: Add, Edit, w40 x120 y25 vE, %BO% 58 | Gui, 2: Add, Text, x125 y50, First Turn Stabilize 59 | Gui, 2: Add, Edit, w40 x120 y70 vF, %FTS% 60 | Gui, 2: Add, Text, x125 y95, Second Turn Stabilize 61 | Gui, 2: Add, Edit, w40 x120 y115 vG, %STS% 62 | 63 | Gui, 2: Add, Button, x20 y192 gSaveVars, Save 64 | Gui, 2: Add, Button, x100 y192 gVarDef, Defaults 65 | Gui, Show,w220 h120, GT7 Special Track X AFK 66 | return 67 | 68 | VariableWindow: 69 | Gui, 2: Show, w260 h225, Variables 70 | return 71 | 72 | SaveVars: 73 | Gui, 2:Submit 74 | GuiControlGet, FTEnt, 2:, A 75 | GuiControlGet, FTExi, 2:, B 76 | GuiControlGet, STEnt, 2:, C 77 | GuiControlGet, STExi, 2:, D 78 | GuiControlGet, BO, 2:, D 79 | GuiControlGet, FTS, 2:, D 80 | GuiControlGet, STS, 2:, D 81 | return 82 | 83 | VarDef: 84 | FTEnt = 85 85 | FTExi = 110 86 | STEnt = 205 87 | STExi = 248 88 | BO = 200 89 | FTS = 400 90 | STS = 401 91 | GuiControl, 2:, A, %FTEnt% 92 | GuiControl, 2:, B, %FTExi% 93 | GuiControl, 2:, C, %STEnt% 94 | GuiControl, 2:, D, %STExi% 95 | GuiControl, 2:, E, %BO% 96 | GuiControl, 2:, F, %FTS% 97 | GuiControl, 2:, G, %STS% 98 | return 99 | 100 | ButtonStart: 101 | Gui, Submit, NoHide 102 | id := "" 103 | SetKeyDelay, 100 104 | Process, priority, , High 105 | gosub, GrabRemotePlay 106 | if (id = "") 107 | return 108 | gosub, PauseLoop 109 | CoordMode, Pixel, Screen 110 | CoordMode, ToolTip, Screen 111 | sleep 1000 112 | gosub, AFKLoop 113 | ; ---------- Gui Setup End------------- 114 | 115 | AFKLoop: 116 | /* 117 | Actual Loop for the script, will switch between functions/subroutines for racing/menuing 118 | Some data below for knowing when racing ends/menuing 119 | --------- Window Watches 120 | 121 | --- Next Button (race finished) 122 | Screen: 734, 855 (less often used) 123 | Window: 699, 823 (default) 124 | Client: 691, 792 (recommended) 125 | Color: CACACA (Red=CA Green=CA Blue=CA) 126 | 127 | --- Purple Banner (race finished) 128 | Screen: 761, 823 (less often used) 129 | Window: 726, 791 (default) 130 | Client: 718, 760 (recommended) 131 | Color: 481A63 (Red=48 Green=1A Blue=63) 132 | 133 | (Race Finished: Enter 6x) 134 | Right 1x) 135 | Enter 1x) 136 | */ 137 | 138 | ; Enter race 139 | loop{ 140 | gosub, PressX 141 | Sleep, 5600 ; This is dependent on load time, probably different for ps4 version 142 | 143 | gosub, Race 144 | gosub, Menu 145 | } 146 | return 147 | 148 | PressX: 149 | ; Just for menuing, does not hold X down 150 | ControlSend,, {%accel% down}, ahk_id %id% 151 | Sleep, 200 152 | ControlSend,, {%accel% up}, ahk_id %id% 153 | return 154 | 155 | PressRight: 156 | ; For turning 157 | ControlSend,, {%turnRight% down}, ahk_id %id% 158 | Sleep, 50 159 | ControlSend,, {%turnRight% up}, ahk_id %id% 160 | return 161 | 162 | Race: 163 | ; Hold Acceleration and manage turning 164 | timer := 0 165 | ControlSend,, {%accel% down}, ahk_id %id% 166 | Sleep, 2200 167 | gosub, BeginOvertake 168 | 169 | /* Potential tuning here 170 | start_time := A_TickCount 171 | firstTurnAt := FTEnt*1000+start_time 172 | firstTurnDone := FTExi*1000+start_time 173 | secTurnAt := STEnt*1000+start_time 174 | secTurnDone := STExi*1000+start_time 175 | 176 | 177 | Loop { 178 | timer += 1 179 | Sleep, 1000 180 | ToolTip, %timer%, 400, 400 181 | } Until A_TickCount - start_time > FTEnt*1000 182 | 183 | ;begin first turn 184 | Loop { 185 | timer += 1 186 | Sleep, 750 187 | ToolTip, %timer%, 400, 400 188 | gosub, PressRight 189 | } Until A_TickCount - start_time > FTExi*1000 190 | 191 | ;end first turn 192 | Loop { 193 | timer += 1 194 | Sleep, 1000 195 | ToolTip, %timer%, 400, 400 196 | } Until A_TickCount - start_time > STEnt*1000 197 | 198 | ;begin second turn 199 | Loop { 200 | timer += 1 201 | Sleep, 750 202 | ToolTip, %timer%, 400, 400 203 | gosub, PressRight 204 | } Until A_TickCount - start_time > STExi*1000 205 | */ 206 | loop, %STExi% { 207 | timer += 1 208 | Sleep, 1000 209 | ToolTip, %timer%, 400, 400 210 | } 211 | 212 | loop, 20 { 213 | timer += 1 214 | Sleep, 1000 215 | ToolTip, %timer%, 400, 400 216 | } 217 | 218 | /* 219 | ; This section detects the end of the race. Can be used to be faster/more accurate at the ending but good timing takes less computer resources 220 | loop { 221 | PixelSearch, x, y, 697, 821, 701, 825, 0xCACACA, 20, Fast RGB 222 | If (ErrorLevel != 0) { ; race finished 223 | Sleep, 1000 224 | } 225 | else{ 226 | ToolTip, Race Finished, 400, 400 227 | break 228 | } 229 | 230 | 231 | } 232 | */ 233 | 234 | ControlSend,, {%accel% up}, ahk_id %id% 235 | return 236 | 237 | 238 | BeginOvertake: 239 | ; Overtake the first car by going left of it towards the rail 240 | ; Stablize before hitting rail 241 | ToolTip, Adjusting Car, 400, 400 242 | ControlSend,, {%turnLeft% down}, ahk_id %id% 243 | Sleep, %BO% 244 | ControlSend,, {%turnLeft% up}, ahk_id %id% 245 | Sleep, 5500 246 | 247 | 248 | return 249 | 250 | 251 | Menu: 252 | loop, 8{ 253 | gosub, PressX 254 | ToolTip, %A_Index% X, 400, 400 255 | Sleep, 1400 256 | } 257 | Sleep, 2000 258 | ToolTip, Press right, 400, 400 259 | ControlSend,, {%turnRight% down}, ahk_id %id% 260 | Sleep, %BO% 261 | ControlSend,, {%turnRight% up}, ahk_id %id% 262 | Sleep, 500 263 | ToolTip, Press X, 400, 400 264 | gosub, PressX 265 | Sleep, 3000 266 | return 267 | 268 | 269 | ;; General Functions for AHK 270 | 271 | GrabRemotePlay: 272 | WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe 273 | if (remotePlay_id = 0) 274 | { 275 | MsgBox, PS4 Remote Play not found 276 | return 277 | } 278 | Loop, %remotePlay_id% 279 | { 280 | id := remotePlay_id%A_Index% 281 | WinGetTitle, title, % "ahk_id " id 282 | If InStr(title, "PS Remote Play") 283 | break 284 | } 285 | WinGetClass, remotePlay_class, ahk_id %id% 286 | WinMove, ahk_id %id%,, 0, 0, 640, 360 287 | ControlFocus,, ahk_class %remotePlay_class% 288 | WinActivate, ahk_id %id% 289 | return 290 | 291 | 292 | PauseLoop: 293 | ControlSend,, {%accel% up}, ahk_id %id% 294 | ControlSend,, {%turnLeft% up}, ahk_id %id% 295 | ControlSend,, {%turnRight% up}, ahk_id %id% 296 | return 297 | 298 | GuiClose: 299 | gosub, PauseLoop 300 | ExitApp 301 | 302 | ^Esc::ExitApp -------------------------------------------------------------------------------- /python_scripts/README.md: -------------------------------------------------------------------------------- 1 | # race_in_circles 2 | 3 | The `race_in_circles.py` script allows you to automate racing circular tracks using pyautogui and PS Remote Play. NOTE: The track MUST be circular. I think the script should work on any platform. 4 | 5 | ## Instructions 6 | 7 | All you need to do is open PS Remote Play and then navigate to the race start screen for the track you want to automate. This is the screen with `Start`, `Settings`, and `Exit` buttons. Make sure that the remote play window is in the middle of your primary monitor because the script clicks the center of the screen to get the winow's focus. 8 | 9 | Next, open a terminal with administrator privileges (I had to use administrator privileges, but you might not have to). Navigate to the directory containing this script and run it: 10 | 11 | ```bash 12 | py race_in_circles.py 13 | ``` 14 | 15 | Voila! You are now racing in circles. 16 | 17 | By default this will race around a circular track with left turns for 200 seconds before navigating through the menus to restart the race. You can change the behavior by passing some command line arguments. 18 | 19 | - To change the side of the track you hug, you can pass the flag `--direction=DIRECTION`. By default you hug the `right` rail. You can also simply pass `-left` or `-l` or `-right` or `-r`. 20 | - You can change the duration with `--duration=DURATION`, where `DURATION` is the number of seconds that the race takes. You can also simply pass a number, like `200`. To get a sense for how long the race takes, start the script with a long duration, say `1000` seconds, and see how long it takes to navigate the course and then restart the script using the new duration (you should add some padding to account for collisions, maybe +10 seconds to be safe). 21 | 22 | The following command will automate a 120 second race where you hug the left hand rail of the course: 23 | 24 | ```bash 25 | py race_in_circles.py --direction=left --duration=120 26 | ``` 27 | 28 | Another command that does the same thing: 29 | 30 | ```bash 31 | py race_in_circles.py -left 120 32 | ``` 33 | 34 | ## Notes 35 | 36 | Right now the script simply navigates through the menus for standard races and runs a race based on timing, meaning if you spin out or something the timing will likely be off. 37 | 38 | If you want to automate a different event, say a championship series, you can edit the script with new menu navigation commands. These are self explanatory in the script. 39 | 40 | -------------------------------------------------------------------------------- /python_scripts/race_in_circles.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import time 3 | import random 4 | import pyautogui 5 | 6 | # Default parameters - these can be overridden with command 7 | # line arguments. See end of script for details. 8 | RACE_DURATION = 200 9 | DIRECTION = "right" 10 | SILENCE = False 11 | 12 | 13 | def press(key: str) -> None: 14 | """Press a key. 15 | 16 | Using vanilla `pyautogui.press()` will not register the keystroke 17 | because GT requires you hold a keypress for a small duration.""" 18 | with pyautogui.hold(key): 19 | time.sleep(0.2) 20 | 21 | 22 | def hold(key: str, duration: float) -> None: 23 | """Hold a key for some duration.""" 24 | 25 | with pyautogui.hold(key): 26 | time.sleep(duration) 27 | 28 | 29 | def ride_rail(direction: str) -> None: 30 | """ 31 | This will drive a car around any convex hull while hugging 32 | the `direction` rail. If you pass `left`, your car will hug 33 | the left rail, thus allowing you to go around righthand turns. 34 | """ 35 | 36 | race_start = time.time() 37 | with pyautogui.hold("up"): 38 | while time.time() - race_start < RACE_DURATION: 39 | hold(direction, (random.randrange(200) / 1000)) 40 | time.sleep((random.randrange(100) / 100)) 41 | 42 | 43 | def race(direction: str) -> None: 44 | """`direction` is the rail to hug, not the direction to turn!""" 45 | 46 | ride_rail(direction) 47 | 48 | 49 | def end_race() -> None: 50 | """Navigate through post-race menus and replay.""" 51 | 52 | commands = [ 53 | "enter", 54 | "enter", 55 | "enter", 56 | "enter", 57 | "enter", 58 | "enter", 59 | "enter", 60 | "right", 61 | "enter", 62 | "down", 63 | "down", 64 | "down", 65 | "left", 66 | "left", 67 | "enter", 68 | ] 69 | for command in commands: 70 | press(command) 71 | time.sleep((random.randrange(500) / 1000) + 2) 72 | 73 | 74 | def start_race(first: bool) -> None: 75 | """Initiate race from the start race menu.""" 76 | if first: 77 | # Click center of screen to focus remote play window. 78 | # You can reposition and resize remote play window, just 79 | # make sure you update where you click. I don't know how to 80 | # use pyautogui in headless mode. 81 | width, height = pyautogui.size() 82 | center = width / 2, height / 2 83 | pyautogui.moveTo(center) 84 | pyautogui.click() 85 | time.sleep(1) 86 | 87 | # This is the button sequence you press when the 'replay' 88 | # button IS NOT visible on the race start screen. 89 | press("down") 90 | press("down") 91 | press("down") 92 | press("left") 93 | press("enter") 94 | else: 95 | # This is the button sequence you press when the 'replay' 96 | # button IS visible on the race start screen. 97 | press("down") 98 | press("down") 99 | press("down") 100 | press("left") 101 | press("left") 102 | press("enter") 103 | 104 | 105 | if __name__ == "__main__": 106 | 107 | args = sys.argv 108 | for arg in args[1:]: 109 | if "=" in arg: 110 | flag, value = arg.split("=") 111 | if flag == "--direction": 112 | DIRECTION = value 113 | if flag == "--duration" and value.isdigit(): 114 | RACE_DURATION = int(value) 115 | else: 116 | if arg == "-left" or arg == "-l": 117 | DIRECTION = "left" 118 | if arg == "-right" or arg == "-r": 119 | DIRECTION = "right" 120 | if arg == "-silence": 121 | SILENCE = True 122 | if arg.isdigit(): 123 | RACE_DURATION = int(value) 124 | 125 | first = True 126 | while True: 127 | start = time.time() 128 | start_race(first) 129 | first = False 130 | race(DIRECTION) 131 | end_race() 132 | end = time.time() 133 | duration = end - start 134 | print(duration, flush=True) 135 | 136 | if not SILENCE: 137 | print(f"{(((60*60) / duration)):.2f} races/hour", flush=True) 138 | --------------------------------------------------------------------------------