mirror of
https://github.com/bnowakow/GT7-Scripts.git
synced 2026-08-10 14:39:01 +00:00
initial commit
This commit is contained in:
@@ -0,0 +1,211 @@
|
|||||||
|
#include %A_LineFile%\..\CLR.ahk
|
||||||
|
|
||||||
|
; Static class, holds ViGEm Client instance
|
||||||
|
class ViGEmWrapper {
|
||||||
|
static asm := 0
|
||||||
|
static client := 0
|
||||||
|
|
||||||
|
Init(){
|
||||||
|
if (this.client == 0){
|
||||||
|
this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateInstance(cls){
|
||||||
|
return this.asm.CreateInstance(cls)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
; Base class for ViGEm "Targets" (Controller types - eg xb360 / ds4) to inherit from
|
||||||
|
class ViGEmTarget {
|
||||||
|
target := 0
|
||||||
|
helperClass := ""
|
||||||
|
controllerClass := ""
|
||||||
|
|
||||||
|
__New(){
|
||||||
|
;~ this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
|
||||||
|
ViGEmWrapper.Init()
|
||||||
|
this.Instance := ViGEmWrapper.CreateInstance(this.helperClass)
|
||||||
|
|
||||||
|
if (this.Instance.OkCheck() != "OK"){
|
||||||
|
msgbox ViGEmWrapper.dll failed to load!
|
||||||
|
ExitApp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SendReport(){
|
||||||
|
this.Instance.SendReport()
|
||||||
|
}
|
||||||
|
|
||||||
|
SubscribeFeedback(callback){
|
||||||
|
this.Instance.SubscribeFeedback(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; DS4 (DualShock 4 for Playstation 4)
|
||||||
|
class ViGEmDS4 extends ViGEmTarget {
|
||||||
|
helperClass := "ViGEmWrapper.Ds4"
|
||||||
|
__New(){
|
||||||
|
static buttons := {Square: 16, Cross: 32, Circle: 64, Triangle: 128, L1: 256, R1: 512, L2: 1024, R2: 2048
|
||||||
|
, Share: 4096, Options: 8192, LS: 16384, RS: 32768 }
|
||||||
|
static specialButtons := {Ps: 1, TouchPad: 2}
|
||||||
|
static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
|
||||||
|
|
||||||
|
this.Buttons := {}
|
||||||
|
for name, id in buttons {
|
||||||
|
this.Buttons[name] := new this._ButtonHelper(this, id)
|
||||||
|
}
|
||||||
|
for name, id in specialButtons {
|
||||||
|
this.Buttons[name] := new this._SpecialButtonHelper(this, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Axes := {}
|
||||||
|
for name, id in axes {
|
||||||
|
this.Axes[name] := new this._AxisHelper(this, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Dpad := new this._DpadHelper(this)
|
||||||
|
base.__New()
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ButtonHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetButtonState(this._Id, state)
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SpecialButtonHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetSpecialButtonState(this._Id, state)
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AxisHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertAxis(state){
|
||||||
|
return round(state * 2.55)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DpadHelper {
|
||||||
|
__New(parent){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
static dPadDirections := {Up: 0, UpRight: 1, Right: 2, DownRight: 3, Down: 4, DownLeft: 5, Left: 6, UpLeft: 7, None: 8}
|
||||||
|
this._Parent.Instance.SetDpadState(dPadDirections[state])
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Xb360
|
||||||
|
class ViGEmXb360 extends ViGEmTarget {
|
||||||
|
helperClass := "ViGEmWrapper.Xb360"
|
||||||
|
__New(){
|
||||||
|
static buttons := {A: 4096, B: 8192, X: 16384, Y: 32768, LB: 256, RB: 512, LS: 64, RS: 128, Back: 32, Start: 16, Xbox: 1024}
|
||||||
|
static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
|
||||||
|
|
||||||
|
this.Buttons := {}
|
||||||
|
for name, id in buttons {
|
||||||
|
this.Buttons[name] := new this._ButtonHelper(this, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Axes := {}
|
||||||
|
for name, id in axes {
|
||||||
|
this.Axes[name] := new this._AxisHelper(this, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Dpad := new this._DpadHelper(this)
|
||||||
|
|
||||||
|
base.__New()
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ButtonHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetButtonState(this._Id, state)
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AxisHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertAxis(state){
|
||||||
|
value := round((state * 655.36) - 32768)
|
||||||
|
if (value == 32768)
|
||||||
|
return 32767
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DpadHelper {
|
||||||
|
_DpadStates := {1:0, 8:0, 2:0, 4:0} ; Up, Right, Down, Left
|
||||||
|
__New(parent){
|
||||||
|
this._Parent := parent
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
static dpadDirections := { None: {1:0, 8:0, 2:0, 4:0}
|
||||||
|
, Up: {1:1, 8:0, 2:0, 4:0}
|
||||||
|
, UpRight: {1:1, 8:1, 2:0, 4:0}
|
||||||
|
, Right: {1:0, 8:1, 2:0, 4:0}
|
||||||
|
, DownRight: {1:0, 8:1, 2:1, 4:0}
|
||||||
|
, Down: {1:0, 8:0, 2:1, 4:0}
|
||||||
|
, DownLeft: {1:0, 8:0, 2:1, 4:1}
|
||||||
|
, Left: {1:0, 8:0, 2:0, 4:1}
|
||||||
|
, UpLeft: {1:1, 8:0, 2:0, 4:1}}
|
||||||
|
newStates := dpadDirections[state]
|
||||||
|
for id, newState in newStates {
|
||||||
|
oldState := this._DpadStates[id]
|
||||||
|
if (oldState != newState){
|
||||||
|
this._DpadStates[id] := newState
|
||||||
|
this._Parent.Instance.SetButtonState(id, newState)
|
||||||
|
}
|
||||||
|
this._Parent.SendReport()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
; ==========================================================
|
||||||
|
; .NET Framework Interop
|
||||||
|
; https://autohotkey.com/boards/viewtopic.php?t=4633
|
||||||
|
; ==========================================================
|
||||||
|
;
|
||||||
|
; Author: Lexikos
|
||||||
|
; Version: 1.2
|
||||||
|
; Requires: AutoHotkey_L v1.0.96+
|
||||||
|
;
|
||||||
|
|
||||||
|
CLR_LoadLibrary(AssemblyName, AppDomain=0)
|
||||||
|
{
|
||||||
|
if !AppDomain
|
||||||
|
AppDomain := CLR_GetDefaultDomain()
|
||||||
|
e := ComObjError(0)
|
||||||
|
Loop 1 {
|
||||||
|
if assembly := AppDomain.Load_2(AssemblyName)
|
||||||
|
break
|
||||||
|
static null := ComObject(13,0)
|
||||||
|
args := ComObjArray(0xC, 1), args[0] := AssemblyName
|
||||||
|
typeofAssembly := AppDomain.GetType().Assembly.GetType()
|
||||||
|
if assembly := typeofAssembly.InvokeMember_3("LoadWithPartialName", 0x158, null, null, args)
|
||||||
|
break
|
||||||
|
if assembly := typeofAssembly.InvokeMember_3("LoadFrom", 0x158, null, null, args)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
ComObjError(e)
|
||||||
|
return assembly
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_CreateObject(Assembly, TypeName, Args*)
|
||||||
|
{
|
||||||
|
if !(argCount := Args.MaxIndex())
|
||||||
|
return Assembly.CreateInstance_2(TypeName, true)
|
||||||
|
|
||||||
|
vargs := ComObjArray(0xC, argCount)
|
||||||
|
Loop % argCount
|
||||||
|
vargs[A_Index-1] := Args[A_Index]
|
||||||
|
|
||||||
|
static Array_Empty := ComObjArray(0xC,0), null := ComObject(13,0)
|
||||||
|
|
||||||
|
return Assembly.CreateInstance_3(TypeName, true, 0, null, vargs, null, Array_Empty)
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_CompileC#(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
|
||||||
|
{
|
||||||
|
return CLR_CompileAssembly(Code, References, "System", "Microsoft.CSharp.CSharpCodeProvider", AppDomain, FileName, CompilerOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_CompileVB(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
|
||||||
|
{
|
||||||
|
return CLR_CompileAssembly(Code, References, "System", "Microsoft.VisualBasic.VBCodeProvider", AppDomain, FileName, CompilerOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_StartDomain(ByRef AppDomain, BaseDirectory="")
|
||||||
|
{
|
||||||
|
static null := ComObject(13,0)
|
||||||
|
args := ComObjArray(0xC, 5), args[0] := "", args[2] := BaseDirectory, args[4] := ComObject(0xB,false)
|
||||||
|
AppDomain := CLR_GetDefaultDomain().GetType().InvokeMember_3("CreateDomain", 0x158, null, null, args)
|
||||||
|
return A_LastError >= 0
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_StopDomain(ByRef AppDomain)
|
||||||
|
{ ; ICorRuntimeHost::UnloadDomain
|
||||||
|
DllCall("SetLastError", "uint", hr := DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+20*A_PtrSize), "ptr", RtHst, "ptr", ComObjValue(AppDomain))), AppDomain := ""
|
||||||
|
return hr >= 0
|
||||||
|
}
|
||||||
|
|
||||||
|
; NOTE: IT IS NOT NECESSARY TO CALL THIS FUNCTION unless you need to load a specific version.
|
||||||
|
CLR_Start(Version="") ; returns ICorRuntimeHost*
|
||||||
|
{
|
||||||
|
static RtHst := 0
|
||||||
|
; The simple method gives no control over versioning, and seems to load .NET v2 even when v4 is present:
|
||||||
|
; return RtHst ? RtHst : (RtHst:=COM_CreateObject("CLRMetaData.CorRuntimeHost","{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}"), DllCall(NumGet(NumGet(RtHst+0)+40),"uint",RtHst))
|
||||||
|
if RtHst
|
||||||
|
return RtHst
|
||||||
|
EnvGet SystemRoot, SystemRoot
|
||||||
|
if Version =
|
||||||
|
Loop % SystemRoot "\Microsoft.NET\Framework" (A_PtrSize=8?"64":"") "\*", 2
|
||||||
|
if (FileExist(A_LoopFileFullPath "\mscorlib.dll") && A_LoopFileName > Version)
|
||||||
|
Version := A_LoopFileName
|
||||||
|
if DllCall("mscoree\CorBindToRuntimeEx", "wstr", Version, "ptr", 0, "uint", 0
|
||||||
|
, "ptr", CLR_GUID(CLSID_CorRuntimeHost, "{CB2F6723-AB3A-11D2-9C40-00C04FA30A3E}")
|
||||||
|
, "ptr", CLR_GUID(IID_ICorRuntimeHost, "{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}")
|
||||||
|
, "ptr*", RtHst) >= 0
|
||||||
|
DllCall(NumGet(NumGet(RtHst+0)+10*A_PtrSize), "ptr", RtHst) ; Start
|
||||||
|
return RtHst
|
||||||
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
; INTERNAL FUNCTIONS
|
||||||
|
;
|
||||||
|
|
||||||
|
CLR_GetDefaultDomain()
|
||||||
|
{
|
||||||
|
static defaultDomain := 0
|
||||||
|
if !defaultDomain
|
||||||
|
{ ; ICorRuntimeHost::GetDefaultDomain
|
||||||
|
if DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+13*A_PtrSize), "ptr", RtHst, "ptr*", p:=0) >= 0
|
||||||
|
defaultDomain := ComObject(p), ObjRelease(p)
|
||||||
|
}
|
||||||
|
return defaultDomain
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_CompileAssembly(Code, References, ProviderAssembly, ProviderType, AppDomain=0, FileName="", CompilerOptions="")
|
||||||
|
{
|
||||||
|
if !AppDomain
|
||||||
|
AppDomain := CLR_GetDefaultDomain()
|
||||||
|
|
||||||
|
if !(asmProvider := CLR_LoadLibrary(ProviderAssembly, AppDomain))
|
||||||
|
|| !(codeProvider := asmProvider.CreateInstance(ProviderType))
|
||||||
|
|| !(codeCompiler := codeProvider.CreateCompiler())
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if !(asmSystem := (ProviderAssembly="System") ? asmProvider : CLR_LoadLibrary("System", AppDomain))
|
||||||
|
return 0
|
||||||
|
|
||||||
|
; Convert | delimited list of references into an array.
|
||||||
|
StringSplit, Refs, References, |, %A_Space%%A_Tab%
|
||||||
|
aRefs := ComObjArray(8, Refs0)
|
||||||
|
Loop % Refs0
|
||||||
|
aRefs[A_Index-1] := Refs%A_Index%
|
||||||
|
|
||||||
|
; Set parameters for compiler.
|
||||||
|
prms := CLR_CreateObject(asmSystem, "System.CodeDom.Compiler.CompilerParameters", aRefs)
|
||||||
|
, prms.OutputAssembly := FileName
|
||||||
|
, prms.GenerateInMemory := FileName=""
|
||||||
|
, prms.GenerateExecutable := SubStr(FileName,-3)=".exe"
|
||||||
|
, prms.CompilerOptions := CompilerOptions
|
||||||
|
, prms.IncludeDebugInformation := true
|
||||||
|
|
||||||
|
; Compile!
|
||||||
|
compilerRes := codeCompiler.CompileAssemblyFromSource(prms, Code)
|
||||||
|
|
||||||
|
if error_count := (errors := compilerRes.Errors).Count
|
||||||
|
{
|
||||||
|
error_text := ""
|
||||||
|
Loop % error_count
|
||||||
|
error_text .= ((e := errors.Item[A_Index-1]).IsWarning ? "Warning " : "Error ") . e.ErrorNumber " on line " e.Line ": " e.ErrorText "`n`n"
|
||||||
|
MsgBox, 16, Compilation Failed, %error_text%
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
; Success. Return Assembly object or path.
|
||||||
|
return compilerRes[FileName="" ? "CompiledAssembly" : "PathToAssembly"]
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_GUID(ByRef GUID, sGUID)
|
||||||
|
{
|
||||||
|
VarSetCapacity(GUID, 16, 0)
|
||||||
|
return DllCall("ole32\CLSIDFromString", "wstr", sGUID, "ptr", &GUID) >= 0 ? &GUID : ""
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,504 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
t := 220000
|
||||||
|
intensity := 220
|
||||||
|
delay := 160
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
color_check1 := 0xFD3C37
|
||||||
|
color_check2 := 0x4DCF75
|
||||||
|
c1_alt := false
|
||||||
|
color_2_delay := 1500
|
||||||
|
|
||||||
|
|
||||||
|
; resolution parameters and pixel search locations
|
||||||
|
ps_win_width := 640
|
||||||
|
ps_win_height := 360
|
||||||
|
pix1x := 247
|
||||||
|
pix1y := 65
|
||||||
|
pix2x := 342
|
||||||
|
pix2y := 362
|
||||||
|
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
Gui, Add, Button, x15 y70 w70 default gGetColo_p, ColorP1
|
||||||
|
Gui, Add, Button, x110 y70 w70 default gGetColo_g, ColorP2
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
Gui, Add, Radio, Group x15 y100 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
Gui, Add, Radio, x70 y100 altsubmit gPSystem, PS4
|
||||||
|
Gui, Add, Radio, Group x15 y120 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
Gui, 2: Add, Text, x100 y90, Color 2 Delay
|
||||||
|
Gui, 2: Add, Edit, x100 y110 w40 vD, %color_2_delay%
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h150, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
GuiControlGet, color_2_delay, 2:, D
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t = 220000
|
||||||
|
intensity = 220
|
||||||
|
delay := 140
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
GuiControl, 2:, D, %color_2_delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
id := ""
|
||||||
|
SetKeyDelay, 10
|
||||||
|
Process, priority, , High
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
if (id = "")
|
||||||
|
return
|
||||||
|
gosub, PauseLoop
|
||||||
|
CoordMode, Pixel, Screen
|
||||||
|
CoordMode, ToolTip, Screen
|
||||||
|
sleep 1000
|
||||||
|
gosub, AFKLoop
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
;gosub, Menu
|
||||||
|
gosub, PressX
|
||||||
|
DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version
|
||||||
|
gosub, Race
|
||||||
|
gosub, Menu
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PressO:
|
||||||
|
; Just for menuing, does not hold O down
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
; For turning
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 8200)
|
||||||
|
gosub TurnRight
|
||||||
|
/*
|
||||||
|
; 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
|
||||||
|
Screen: 218, 359 (less often used)
|
||||||
|
Window: 222, 357 (default)
|
||||||
|
Client: 214, 326 (recommended)
|
||||||
|
Color: 3F1757 (Red=3F Green=17 Blue=57)
|
||||||
|
|
||||||
|
Screen: 247, 65 (less often used)
|
||||||
|
Window: -129, -376 (default)
|
||||||
|
Client: -129, -376 (recommended)
|
||||||
|
Color: FD3C37 (Red=FD Green=3C Blue=37)
|
||||||
|
|
||||||
|
Screen: 210, 64 (less often used)
|
||||||
|
Window: 210, 64 (default)
|
||||||
|
Client: 202, 33 (recommended)
|
||||||
|
Color: 5091E9 (Red=50 Green=91 Blue=E9)
|
||||||
|
|
||||||
|
Screen: 261, 39 (less often used)
|
||||||
|
Window: 261, 39 (default)
|
||||||
|
Client: 253, 8 (recommended)
|
||||||
|
Color: A774A9 (Red=A7 Green=74 Blue=A9)
|
||||||
|
*/
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, pix1x-2, pix1y-2, pix1x+2, pix1y+2, %color_check1%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 140
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu:
|
||||||
|
if (menu_s = 1){
|
||||||
|
gosub, Menu_pixel
|
||||||
|
}
|
||||||
|
if (menu_s = 2){
|
||||||
|
gosub, Menu_time
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_pixel:
|
||||||
|
;ToolTip, Menuing, 100, 100, Screen
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, pix2x-2, pix2y-2, pix2x+2, pix2y+2, %color_check2%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
gosub, PressX
|
||||||
|
sleep %color_2_delay%
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;ToolTip, Found color 2, 100, 100, Screen
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1200
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_time:
|
||||||
|
loop, 9{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1700
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
PixelTuning:
|
||||||
|
x_ratio := ps_win_width/640
|
||||||
|
y_ratio := ps_win_height/360
|
||||||
|
pix1x := Floor(pix1x*x_ratio)
|
||||||
|
pix1y := Floor(pix1y*y_ratio)
|
||||||
|
pix2x := Floor(pix2x*x_ratio)
|
||||||
|
pix2y := Floor(pix2y*y_ratio)
|
||||||
|
return
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
return
|
||||||
|
|
||||||
|
RPwind:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, -700, -400, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
|
||||||
|
{
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
|
||||||
|
w := NumGet(rect, 8, "int")
|
||||||
|
h := NumGet(rect, 12, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
/*
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/*this section was used to test resoltuion specs
|
||||||
|
*/
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
MsgBox, Width %ps_win_width% Height %ps_win_height% pix1 %pix1x%
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check1 := PixelColorSimple(pix1x, pix1y)
|
||||||
|
;MsgBox, At the screen with [Replay] [Next Race], Press ColorP2
|
||||||
|
c1_alt := true
|
||||||
|
MsgBox, Put this in for color_check1 %color_check1%
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check2 := PixelColorSimple(pix2x, pix2y)
|
||||||
|
c1_alt := false
|
||||||
|
MsgBox, Put this in for color_check2 %color_check2%
|
||||||
|
return
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1){
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
}
|
||||||
|
if (SysCheck = 2){
|
||||||
|
ps_load_time1 := 41500
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 40000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
MenuSel:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (MenuCheck = 1){
|
||||||
|
menu_s := 1
|
||||||
|
}
|
||||||
|
if (MenuCheck = 2){
|
||||||
|
menu_s := 2
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
@@ -0,0 +1,594 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
#Include Lib\Gdip.ahk
|
||||||
|
;#include Lib\AHK-ViGEm-Bus.ahk
|
||||||
|
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
; RUF pink 0x583375
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
t := 220000
|
||||||
|
intensity := 210
|
||||||
|
delay := 160
|
||||||
|
init_delay := 10000
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
box_size := 3
|
||||||
|
color_check1 := 0xBBE044
|
||||||
|
color_check2 := 0xBBE044
|
||||||
|
color_2_delay := 250
|
||||||
|
|
||||||
|
color_tyre_overheat := 0xD42304
|
||||||
|
tyres_overheating := false
|
||||||
|
tyreX := 166
|
||||||
|
tyreY := 364
|
||||||
|
|
||||||
|
; resolution parameters and pixel search locations
|
||||||
|
ps_win_width := 640
|
||||||
|
ps_win_height := 360
|
||||||
|
pix1x := 458
|
||||||
|
pix1y := 114
|
||||||
|
pix2x := 607
|
||||||
|
pix2y := 319
|
||||||
|
tolerance := 20
|
||||||
|
bm_delay := 100
|
||||||
|
box_size := 2
|
||||||
|
|
||||||
|
; 1st load time is the load screen after clicking green 'To Next Race' button
|
||||||
|
ps_load_time1 := 12000
|
||||||
|
; 2nd load time is the load screen after clicking red 'Exit Race' button
|
||||||
|
ps_load_time2 := 6000
|
||||||
|
; 3rd load time is the load screen after selecting 'Pan America' race series
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
Gui, Add, Button, x15 y70 w70 default gGetColo_p, Stuck Leaderboard
|
||||||
|
Gui, Add, Button, x110 y70 w70 default gGetColo_g, Stuck Replay
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
Gui, Add, Radio, Group x15 y115 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
Gui, Add, Radio, x70 y115 altsubmit gPSystem, PS4
|
||||||
|
;Gui, Add, Radio, Group x15 y130 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
;Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
Gui, Add, Button, x70 y135 w70 default gReset, Reset
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
Gui, 2: Add, Text, x100 y90, Color 2 Delay
|
||||||
|
Gui, 2: Add, Edit, x100 y110 w40 vD, %color_2_delay%
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h170, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
GuiControlGet, color_2_delay, 2:, D
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t = 220000
|
||||||
|
intensity = 220
|
||||||
|
delay := 140
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
GuiControl, 2:, D, %color_2_delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
id := ""
|
||||||
|
SetKeyDelay, 10
|
||||||
|
Process, priority, , High
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
if (id = "")
|
||||||
|
return
|
||||||
|
gosub, PauseLoop
|
||||||
|
CoordMode, Pixel, Screen
|
||||||
|
CoordMode, ToolTip, Screen
|
||||||
|
sleep 1000
|
||||||
|
gosub, AFKLoop
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
;gosub, Menu
|
||||||
|
gosub, PressX
|
||||||
|
DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version
|
||||||
|
gosub, Race
|
||||||
|
gosub, Menu
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PressO:
|
||||||
|
; Just for menuing, does not hold O down
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
; For turning
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until tyres_overheating || A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until tyres_overheating || A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
CheckTyresOverheating:
|
||||||
|
tc := BitGrab(tyreX, tyreY, box_size)
|
||||||
|
for i, c in tc
|
||||||
|
{
|
||||||
|
td := Distance(c, color_tyre_overheat)
|
||||||
|
if (td < tolerance ){
|
||||||
|
tyres_overheating := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
RetryRace:
|
||||||
|
Gosub, PauseLoop
|
||||||
|
Sleep 500
|
||||||
|
tyres_overheating := false
|
||||||
|
controller.Buttons.Options.SetState(true)
|
||||||
|
Sleep 500
|
||||||
|
controller.Buttons.Options.SetState(false)
|
||||||
|
Sleep, 500
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Goto, AFKLoop
|
||||||
|
return
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
ToolTip, Racing, 100, 100, Screen
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 8000)
|
||||||
|
ToolTip ; This is to remove tooltip
|
||||||
|
gosub TurnRight
|
||||||
|
loop {
|
||||||
|
break_point := false
|
||||||
|
c1 := BitGrab(pix1x, pix1y, box_size)
|
||||||
|
for i, c in c1
|
||||||
|
{
|
||||||
|
d1 := Distance(c, color_check1)
|
||||||
|
if (d1 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 140
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
ToolTip, Exiting Race, 100, 100, Screen
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu:
|
||||||
|
if (menu_s = 1){
|
||||||
|
gosub, Menu_pixel
|
||||||
|
}
|
||||||
|
if (menu_s = 2){
|
||||||
|
gosub, Menu_time
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_pixel:
|
||||||
|
ToolTip, Exit Race Sequence, 100, 100, Screen
|
||||||
|
loop {
|
||||||
|
break_point := false
|
||||||
|
c2 := BitGrab(pix2x, pix2y, box_size)
|
||||||
|
for i, c in c2
|
||||||
|
{
|
||||||
|
d2 := Distance(c, color_check2)
|
||||||
|
if (d2 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
gosub, PressX
|
||||||
|
sleep %color_2_delay%
|
||||||
|
sleep, %bm_delay%
|
||||||
|
}
|
||||||
|
ToolTip, Exit Leaderboard, 100, 100, Screen
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
ToolTip, Exit Replay, 100, 100, Screen
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
ToolTip, Going to Next Race, 100, 100, Screen
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 100
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 100
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 100
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 100
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
ToolTip, Loading Next Race, 100, 100, Screen
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_time:
|
||||||
|
loop, 9{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1700
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 100
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 400
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
return
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
PixelTuning:
|
||||||
|
x_ratio := ps_win_width/640
|
||||||
|
y_ratio := ps_win_height/360
|
||||||
|
pix1x := Floor(pix1x*x_ratio)
|
||||||
|
pix1y := Floor(pix1y*y_ratio)
|
||||||
|
pix2x := Floor(pix2x*x_ratio)
|
||||||
|
pix2y := Floor(pix2y*y_ratio)
|
||||||
|
tyreX := Floor(tyreX*x_ratio)
|
||||||
|
tyreY := Floor(tyreY*y_ratio)
|
||||||
|
return
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
return
|
||||||
|
|
||||||
|
RPwind:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, -700, -400, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
|
||||||
|
{
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
|
||||||
|
w := NumGet(rect, 8, "int")
|
||||||
|
h := NumGet(rect, 12, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertARGB(ARGB, Convert := 0)
|
||||||
|
{
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
RGB += ARGB
|
||||||
|
RGB := RGB & 0x00FFFFFF
|
||||||
|
if (Convert)
|
||||||
|
RGB := (RGB & 0xFF000000) | ((RGB & 0xFF0000) >> 16) | (RGB & 0x00FF00) | ((RGB & 0x0000FF) << 16)
|
||||||
|
|
||||||
|
return RGB
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
MsgBox, This will test the number of Left/Right presses at the championship selection menu. `nTry this if you have not finished all cafe menus. `nPress OK to test
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
BitGrab(x, y, b)
|
||||||
|
{
|
||||||
|
HWND := WinExist("PS Remote Play")
|
||||||
|
pToken := Gdip_Startup()
|
||||||
|
pBitmap := Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
|
||||||
|
pixs := []
|
||||||
|
for i in range(-1*b, b+1){
|
||||||
|
for j in range(-1*b, b+1){
|
||||||
|
pixel := Gdip_GetPixel(pBitmap,x+i,y+j)
|
||||||
|
rgb := ConvertARGB( pixel )
|
||||||
|
pixs.Push(rgb)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdip_DisposeImage(pBitmap)
|
||||||
|
Gdip_Shutdown(pToken)
|
||||||
|
return pixs
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
{
|
||||||
|
WinGetPos,,, Width, Height, ahk_id %hwnd%
|
||||||
|
hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
|
||||||
|
RegExMatch(A_OsVersion, "\d+", Version)
|
||||||
|
PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
|
||||||
|
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
|
||||||
|
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
|
||||||
|
return pBitmap
|
||||||
|
}
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check1 := PixelColorSimple(pix1x, pix1y)
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check2 := PixelColorSimple(pix2x, pix2y)
|
||||||
|
return
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1){
|
||||||
|
ps_load_time1 := 12000
|
||||||
|
ps_load_time2 := 6000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
}
|
||||||
|
if (SysCheck = 2){
|
||||||
|
ps_load_time1 := 41500
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 40000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
MenuSel:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (MenuCheck = 1){
|
||||||
|
menu_s := 1
|
||||||
|
}
|
||||||
|
if (MenuCheck = 2){
|
||||||
|
menu_s := 2s
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Reset:
|
||||||
|
gosub, PauseLoop
|
||||||
|
Reload
|
||||||
|
Sleep 1000
|
||||||
|
return
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
range(start, stop:="", step:=1) {
|
||||||
|
static range := { _NewEnum: Func("_RangeNewEnum") }
|
||||||
|
if !step
|
||||||
|
throw "range(): Parameter 'step' must not be 0 or blank"
|
||||||
|
if (stop == "")
|
||||||
|
stop := start, start := 0
|
||||||
|
; Formula: r[i] := start + step*i ; r = range object, i = 0-based index
|
||||||
|
; For a postive 'step', the constraints are i >= 0 and r[i] < stop
|
||||||
|
; For a negative 'step', the constraints are i >= 0 and r[i] > stop
|
||||||
|
; No result is returned if r[0] does not meet the value constraint
|
||||||
|
if (step > 0 ? start < stop : start > stop) ;// start == start + step*0
|
||||||
|
return { base: range, start: start, stop: stop, step: step }
|
||||||
|
}
|
||||||
|
|
||||||
|
_RangeNewEnum(r) {
|
||||||
|
static enum := { "Next": Func("_RangeEnumNext") }
|
||||||
|
return { base: enum, r: r, i: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
_RangeEnumNext(enum, ByRef k, ByRef v:="") {
|
||||||
|
stop := enum.r.stop, step := enum.r.step
|
||||||
|
, k := enum.r.start + step*enum.i
|
||||||
|
if (ret := step > 0 ? k < stop : k > stop)
|
||||||
|
enum.i += 1
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
@@ -0,0 +1,728 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
t := 220000
|
||||||
|
intensity := 220
|
||||||
|
delay := 160
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
color_check1 := 0xFD3C37
|
||||||
|
color_check2 := 0x4DCF75
|
||||||
|
c1_alt := false
|
||||||
|
color_2_delay := 1500
|
||||||
|
|
||||||
|
|
||||||
|
; resolution parameters and pixel search locations
|
||||||
|
ps_win_width := 640
|
||||||
|
ps_win_height := 360
|
||||||
|
pix1x := 247
|
||||||
|
pix1y := 65
|
||||||
|
pix2x := 342
|
||||||
|
pix2y := 362
|
||||||
|
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
;Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
;Gui, Add, Button, x15 y70 w70 default gGetColo_p, ColorP1
|
||||||
|
; Gui, Add, Button, x110 y70 w70 default gGetColo_g, ColorP2
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
; Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
; Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
; Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
; Gui, Add, Radio, Group x15 y100 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
; Gui, Add, Radio, x70 y100 altsubmit gPSystem, PS4
|
||||||
|
; Gui, Add, Radio, Group x15 y120 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
; Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
; Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
Gui, 2: Add, Text, x100 y90, Color 2 Delay
|
||||||
|
Gui, 2: Add, Edit, x100 y110 w40 vD, %color_2_delay%
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h150, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
GuiControlGet, color_2_delay, 2:, D
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t = 220000
|
||||||
|
intensity = 220
|
||||||
|
delay := 140
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
GuiControl, 2:, D, %color_2_delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
gosub, PixelTuning
|
||||||
|
|
||||||
|
SetKeyDelay, 10
|
||||||
|
|
||||||
|
;get to upper left hand menu
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to options menu
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to Controllers menu
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to wireless controller 1p
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change steering controlls
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change pedal controlls
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change Nitros to down arrow
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;apply settings
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;back to menu
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
;enter world circuits
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 5000
|
||||||
|
|
||||||
|
;enter panam
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change car - selecing twice if good car was already selected
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;enter race
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 12000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
;change gearbox to auto
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
;start race
|
||||||
|
gosub, PressLeft
|
||||||
|
; gosub, PressX
|
||||||
|
|
||||||
|
; ;pause race
|
||||||
|
; Sleep, 5000
|
||||||
|
; ; TODO below doesn't go to exit menu FIXME
|
||||||
|
; gosub, PressO
|
||||||
|
; gosub, PressRight
|
||||||
|
|
||||||
|
MsgBox, Settings set for AFK
|
||||||
|
|
||||||
|
return
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
;gosub, Menu
|
||||||
|
gosub, PressX
|
||||||
|
DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version
|
||||||
|
gosub, Race
|
||||||
|
gosub, Menu
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressO:
|
||||||
|
; Just for menuing, does not hold O down
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressLeft:
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressDown:
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressUp:
|
||||||
|
ControlSend,, {%brake% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%brake% up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 8200)
|
||||||
|
gosub TurnRight
|
||||||
|
/*
|
||||||
|
; 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
|
||||||
|
Screen: 218, 359 (less often used)
|
||||||
|
Window: 222, 357 (default)
|
||||||
|
Client: 214, 326 (recommended)
|
||||||
|
Color: 3F1757 (Red=3F Green=17 Blue=57)
|
||||||
|
|
||||||
|
Screen: 247, 65 (less often used)
|
||||||
|
Window: -129, -376 (default)
|
||||||
|
Client: -129, -376 (recommended)
|
||||||
|
Color: FD3C37 (Red=FD Green=3C Blue=37)
|
||||||
|
|
||||||
|
Screen: 210, 64 (less often used)
|
||||||
|
Window: 210, 64 (default)
|
||||||
|
Client: 202, 33 (recommended)
|
||||||
|
Color: 5091E9 (Red=50 Green=91 Blue=E9)
|
||||||
|
|
||||||
|
Screen: 261, 39 (less often used)
|
||||||
|
Window: 261, 39 (default)
|
||||||
|
Client: 253, 8 (recommended)
|
||||||
|
Color: A774A9 (Red=A7 Green=74 Blue=A9)
|
||||||
|
*/
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, pix1x-2, pix1y-2, pix1x+2, pix1y+2, %color_check1%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 140
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu:
|
||||||
|
if (menu_s = 1){
|
||||||
|
gosub, Menu_pixel
|
||||||
|
}
|
||||||
|
if (menu_s = 2){
|
||||||
|
gosub, Menu_time
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_pixel:
|
||||||
|
;ToolTip, Menuing, 100, 100, Screen
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, pix2x-2, pix2y-2, pix2x+2, pix2y+2, %color_check2%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
gosub, PressX
|
||||||
|
sleep %color_2_delay%
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;ToolTip, Found color 2, 100, 100, Screen
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1200
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_time:
|
||||||
|
loop, 9{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1700
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
PixelTuning:
|
||||||
|
x_ratio := ps_win_width/640
|
||||||
|
y_ratio := ps_win_height/360
|
||||||
|
pix1x := Floor(pix1x*x_ratio)
|
||||||
|
pix1y := Floor(pix1y*y_ratio)
|
||||||
|
pix2x := Floor(pix2x*x_ratio)
|
||||||
|
pix2y := Floor(pix2y*y_ratio)
|
||||||
|
return
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
return
|
||||||
|
|
||||||
|
RPwind:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, -700, -400, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
|
||||||
|
{
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
|
||||||
|
w := NumGet(rect, 8, "int")
|
||||||
|
h := NumGet(rect, 12, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
gosub, PixelTuning
|
||||||
|
|
||||||
|
SetKeyDelay, 10
|
||||||
|
|
||||||
|
;get to upper left hand menu
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to options menu
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to Controllers menu
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to wireless controller 1p
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change steering controlls
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change pedal controlls
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;disable camera control
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;apply settings
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;back to menu
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
;enter world circuits
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 5000
|
||||||
|
|
||||||
|
;enter panam
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;enter race
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 12000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
;change gearbox to manual
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
;leave race
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 8000
|
||||||
|
|
||||||
|
;go back to main menu
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
MsgBox, Reverted settings after AFK
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check1 := PixelColorSimple(pix1x, pix1y)
|
||||||
|
;MsgBox, At the screen with [Replay] [Next Race], Press ColorP2
|
||||||
|
c1_alt := true
|
||||||
|
MsgBox, Put this in for color_check1 %color_check1%
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check2 := PixelColorSimple(pix2x, pix2y)
|
||||||
|
c1_alt := false
|
||||||
|
MsgBox, Put this in for color_check2 %color_check2%
|
||||||
|
return
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1){
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
}
|
||||||
|
if (SysCheck = 2){
|
||||||
|
ps_load_time1 := 41500
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 40000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
MenuSel:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (MenuCheck = 1){
|
||||||
|
menu_s := 1
|
||||||
|
}
|
||||||
|
if (MenuCheck = 2){
|
||||||
|
menu_s := 2
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
|
|
||||||
@@ -0,0 +1,211 @@
|
|||||||
|
#include %A_LineFile%\..\CLR.ahk
|
||||||
|
|
||||||
|
; Static class, holds ViGEm Client instance
|
||||||
|
class ViGEmWrapper {
|
||||||
|
static asm := 0
|
||||||
|
static client := 0
|
||||||
|
|
||||||
|
Init(){
|
||||||
|
if (this.client == 0){
|
||||||
|
this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateInstance(cls){
|
||||||
|
return this.asm.CreateInstance(cls)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
; Base class for ViGEm "Targets" (Controller types - eg xb360 / ds4) to inherit from
|
||||||
|
class ViGEmTarget {
|
||||||
|
target := 0
|
||||||
|
helperClass := ""
|
||||||
|
controllerClass := ""
|
||||||
|
|
||||||
|
__New(){
|
||||||
|
;~ this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
|
||||||
|
ViGEmWrapper.Init()
|
||||||
|
this.Instance := ViGEmWrapper.CreateInstance(this.helperClass)
|
||||||
|
|
||||||
|
if (this.Instance.OkCheck() != "OK"){
|
||||||
|
msgbox ViGEmWrapper.dll failed to load!
|
||||||
|
ExitApp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SendReport(){
|
||||||
|
this.Instance.SendReport()
|
||||||
|
}
|
||||||
|
|
||||||
|
SubscribeFeedback(callback){
|
||||||
|
this.Instance.SubscribeFeedback(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; DS4 (DualShock 4 for Playstation 4)
|
||||||
|
class ViGEmDS4 extends ViGEmTarget {
|
||||||
|
helperClass := "ViGEmWrapper.Ds4"
|
||||||
|
__New(){
|
||||||
|
static buttons := {Square: 16, Cross: 32, Circle: 64, Triangle: 128, L1: 256, R1: 512, L2: 1024, R2: 2048
|
||||||
|
, Share: 4096, Options: 8192, LS: 16384, RS: 32768 }
|
||||||
|
static specialButtons := {Ps: 1, TouchPad: 2}
|
||||||
|
static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
|
||||||
|
|
||||||
|
this.Buttons := {}
|
||||||
|
for name, id in buttons {
|
||||||
|
this.Buttons[name] := new this._ButtonHelper(this, id)
|
||||||
|
}
|
||||||
|
for name, id in specialButtons {
|
||||||
|
this.Buttons[name] := new this._SpecialButtonHelper(this, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Axes := {}
|
||||||
|
for name, id in axes {
|
||||||
|
this.Axes[name] := new this._AxisHelper(this, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Dpad := new this._DpadHelper(this)
|
||||||
|
base.__New()
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ButtonHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetButtonState(this._Id, state)
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SpecialButtonHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetSpecialButtonState(this._Id, state)
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AxisHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertAxis(state){
|
||||||
|
return round(state * 2.55)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DpadHelper {
|
||||||
|
__New(parent){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
static dPadDirections := {Up: 0, UpRight: 1, Right: 2, DownRight: 3, Down: 4, DownLeft: 5, Left: 6, UpLeft: 7, None: 8}
|
||||||
|
this._Parent.Instance.SetDpadState(dPadDirections[state])
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Xb360
|
||||||
|
class ViGEmXb360 extends ViGEmTarget {
|
||||||
|
helperClass := "ViGEmWrapper.Xb360"
|
||||||
|
__New(){
|
||||||
|
static buttons := {A: 4096, B: 8192, X: 16384, Y: 32768, LB: 256, RB: 512, LS: 64, RS: 128, Back: 32, Start: 16, Xbox: 1024}
|
||||||
|
static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
|
||||||
|
|
||||||
|
this.Buttons := {}
|
||||||
|
for name, id in buttons {
|
||||||
|
this.Buttons[name] := new this._ButtonHelper(this, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Axes := {}
|
||||||
|
for name, id in axes {
|
||||||
|
this.Axes[name] := new this._AxisHelper(this, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Dpad := new this._DpadHelper(this)
|
||||||
|
|
||||||
|
base.__New()
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ButtonHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetButtonState(this._Id, state)
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AxisHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertAxis(state){
|
||||||
|
value := round((state * 655.36) - 32768)
|
||||||
|
if (value == 32768)
|
||||||
|
return 32767
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DpadHelper {
|
||||||
|
_DpadStates := {1:0, 8:0, 2:0, 4:0} ; Up, Right, Down, Left
|
||||||
|
__New(parent){
|
||||||
|
this._Parent := parent
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
static dpadDirections := { None: {1:0, 8:0, 2:0, 4:0}
|
||||||
|
, Up: {1:1, 8:0, 2:0, 4:0}
|
||||||
|
, UpRight: {1:1, 8:1, 2:0, 4:0}
|
||||||
|
, Right: {1:0, 8:1, 2:0, 4:0}
|
||||||
|
, DownRight: {1:0, 8:1, 2:1, 4:0}
|
||||||
|
, Down: {1:0, 8:0, 2:1, 4:0}
|
||||||
|
, DownLeft: {1:0, 8:0, 2:1, 4:1}
|
||||||
|
, Left: {1:0, 8:0, 2:0, 4:1}
|
||||||
|
, UpLeft: {1:1, 8:0, 2:0, 4:1}}
|
||||||
|
newStates := dpadDirections[state]
|
||||||
|
for id, newState in newStates {
|
||||||
|
oldState := this._DpadStates[id]
|
||||||
|
if (oldState != newState){
|
||||||
|
this._DpadStates[id] := newState
|
||||||
|
this._Parent.Instance.SetButtonState(id, newState)
|
||||||
|
}
|
||||||
|
this._Parent.SendReport()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
; ==========================================================
|
||||||
|
; .NET Framework Interop
|
||||||
|
; https://autohotkey.com/boards/viewtopic.php?t=4633
|
||||||
|
; ==========================================================
|
||||||
|
;
|
||||||
|
; Author: Lexikos
|
||||||
|
; Version: 1.2
|
||||||
|
; Requires: AutoHotkey_L v1.0.96+
|
||||||
|
;
|
||||||
|
|
||||||
|
CLR_LoadLibrary(AssemblyName, AppDomain=0)
|
||||||
|
{
|
||||||
|
if !AppDomain
|
||||||
|
AppDomain := CLR_GetDefaultDomain()
|
||||||
|
e := ComObjError(0)
|
||||||
|
Loop 1 {
|
||||||
|
if assembly := AppDomain.Load_2(AssemblyName)
|
||||||
|
break
|
||||||
|
static null := ComObject(13,0)
|
||||||
|
args := ComObjArray(0xC, 1), args[0] := AssemblyName
|
||||||
|
typeofAssembly := AppDomain.GetType().Assembly.GetType()
|
||||||
|
if assembly := typeofAssembly.InvokeMember_3("LoadWithPartialName", 0x158, null, null, args)
|
||||||
|
break
|
||||||
|
if assembly := typeofAssembly.InvokeMember_3("LoadFrom", 0x158, null, null, args)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
ComObjError(e)
|
||||||
|
return assembly
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_CreateObject(Assembly, TypeName, Args*)
|
||||||
|
{
|
||||||
|
if !(argCount := Args.MaxIndex())
|
||||||
|
return Assembly.CreateInstance_2(TypeName, true)
|
||||||
|
|
||||||
|
vargs := ComObjArray(0xC, argCount)
|
||||||
|
Loop % argCount
|
||||||
|
vargs[A_Index-1] := Args[A_Index]
|
||||||
|
|
||||||
|
static Array_Empty := ComObjArray(0xC,0), null := ComObject(13,0)
|
||||||
|
|
||||||
|
return Assembly.CreateInstance_3(TypeName, true, 0, null, vargs, null, Array_Empty)
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_CompileC#(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
|
||||||
|
{
|
||||||
|
return CLR_CompileAssembly(Code, References, "System", "Microsoft.CSharp.CSharpCodeProvider", AppDomain, FileName, CompilerOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_CompileVB(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
|
||||||
|
{
|
||||||
|
return CLR_CompileAssembly(Code, References, "System", "Microsoft.VisualBasic.VBCodeProvider", AppDomain, FileName, CompilerOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_StartDomain(ByRef AppDomain, BaseDirectory="")
|
||||||
|
{
|
||||||
|
static null := ComObject(13,0)
|
||||||
|
args := ComObjArray(0xC, 5), args[0] := "", args[2] := BaseDirectory, args[4] := ComObject(0xB,false)
|
||||||
|
AppDomain := CLR_GetDefaultDomain().GetType().InvokeMember_3("CreateDomain", 0x158, null, null, args)
|
||||||
|
return A_LastError >= 0
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_StopDomain(ByRef AppDomain)
|
||||||
|
{ ; ICorRuntimeHost::UnloadDomain
|
||||||
|
DllCall("SetLastError", "uint", hr := DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+20*A_PtrSize), "ptr", RtHst, "ptr", ComObjValue(AppDomain))), AppDomain := ""
|
||||||
|
return hr >= 0
|
||||||
|
}
|
||||||
|
|
||||||
|
; NOTE: IT IS NOT NECESSARY TO CALL THIS FUNCTION unless you need to load a specific version.
|
||||||
|
CLR_Start(Version="") ; returns ICorRuntimeHost*
|
||||||
|
{
|
||||||
|
static RtHst := 0
|
||||||
|
; The simple method gives no control over versioning, and seems to load .NET v2 even when v4 is present:
|
||||||
|
; return RtHst ? RtHst : (RtHst:=COM_CreateObject("CLRMetaData.CorRuntimeHost","{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}"), DllCall(NumGet(NumGet(RtHst+0)+40),"uint",RtHst))
|
||||||
|
if RtHst
|
||||||
|
return RtHst
|
||||||
|
EnvGet SystemRoot, SystemRoot
|
||||||
|
if Version =
|
||||||
|
Loop % SystemRoot "\Microsoft.NET\Framework" (A_PtrSize=8?"64":"") "\*", 2
|
||||||
|
if (FileExist(A_LoopFileFullPath "\mscorlib.dll") && A_LoopFileName > Version)
|
||||||
|
Version := A_LoopFileName
|
||||||
|
if DllCall("mscoree\CorBindToRuntimeEx", "wstr", Version, "ptr", 0, "uint", 0
|
||||||
|
, "ptr", CLR_GUID(CLSID_CorRuntimeHost, "{CB2F6723-AB3A-11D2-9C40-00C04FA30A3E}")
|
||||||
|
, "ptr", CLR_GUID(IID_ICorRuntimeHost, "{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}")
|
||||||
|
, "ptr*", RtHst) >= 0
|
||||||
|
DllCall(NumGet(NumGet(RtHst+0)+10*A_PtrSize), "ptr", RtHst) ; Start
|
||||||
|
return RtHst
|
||||||
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
; INTERNAL FUNCTIONS
|
||||||
|
;
|
||||||
|
|
||||||
|
CLR_GetDefaultDomain()
|
||||||
|
{
|
||||||
|
static defaultDomain := 0
|
||||||
|
if !defaultDomain
|
||||||
|
{ ; ICorRuntimeHost::GetDefaultDomain
|
||||||
|
if DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+13*A_PtrSize), "ptr", RtHst, "ptr*", p:=0) >= 0
|
||||||
|
defaultDomain := ComObject(p), ObjRelease(p)
|
||||||
|
}
|
||||||
|
return defaultDomain
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_CompileAssembly(Code, References, ProviderAssembly, ProviderType, AppDomain=0, FileName="", CompilerOptions="")
|
||||||
|
{
|
||||||
|
if !AppDomain
|
||||||
|
AppDomain := CLR_GetDefaultDomain()
|
||||||
|
|
||||||
|
if !(asmProvider := CLR_LoadLibrary(ProviderAssembly, AppDomain))
|
||||||
|
|| !(codeProvider := asmProvider.CreateInstance(ProviderType))
|
||||||
|
|| !(codeCompiler := codeProvider.CreateCompiler())
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if !(asmSystem := (ProviderAssembly="System") ? asmProvider : CLR_LoadLibrary("System", AppDomain))
|
||||||
|
return 0
|
||||||
|
|
||||||
|
; Convert | delimited list of references into an array.
|
||||||
|
StringSplit, Refs, References, |, %A_Space%%A_Tab%
|
||||||
|
aRefs := ComObjArray(8, Refs0)
|
||||||
|
Loop % Refs0
|
||||||
|
aRefs[A_Index-1] := Refs%A_Index%
|
||||||
|
|
||||||
|
; Set parameters for compiler.
|
||||||
|
prms := CLR_CreateObject(asmSystem, "System.CodeDom.Compiler.CompilerParameters", aRefs)
|
||||||
|
, prms.OutputAssembly := FileName
|
||||||
|
, prms.GenerateInMemory := FileName=""
|
||||||
|
, prms.GenerateExecutable := SubStr(FileName,-3)=".exe"
|
||||||
|
, prms.CompilerOptions := CompilerOptions
|
||||||
|
, prms.IncludeDebugInformation := true
|
||||||
|
|
||||||
|
; Compile!
|
||||||
|
compilerRes := codeCompiler.CompileAssemblyFromSource(prms, Code)
|
||||||
|
|
||||||
|
if error_count := (errors := compilerRes.Errors).Count
|
||||||
|
{
|
||||||
|
error_text := ""
|
||||||
|
Loop % error_count
|
||||||
|
error_text .= ((e := errors.Item[A_Index-1]).IsWarning ? "Warning " : "Error ") . e.ErrorNumber " on line " e.Line ": " e.ErrorText "`n`n"
|
||||||
|
MsgBox, 16, Compilation Failed, %error_text%
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
; Success. Return Assembly object or path.
|
||||||
|
return compilerRes[FileName="" ? "CompiledAssembly" : "PathToAssembly"]
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_GUID(ByRef GUID, sGUID)
|
||||||
|
{
|
||||||
|
VarSetCapacity(GUID, 16, 0)
|
||||||
|
return DllCall("ole32\CLSIDFromString", "wstr", sGUID, "ptr", &GUID) >= 0 ? &GUID : ""
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,640 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
#Include Lib\Gdip.ahk
|
||||||
|
#include Lib\AHK-ViGEm-Bus.ahk
|
||||||
|
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
t := 220000
|
||||||
|
init_delay := 9700
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
box_size := 3
|
||||||
|
color_check1 := 0xBBE044
|
||||||
|
color_check2 := 0xBBE044
|
||||||
|
color_2_delay := 1500
|
||||||
|
|
||||||
|
color_tyre_overheat := 0xAF0019
|
||||||
|
color_acquired_flag := 0x80C2E7
|
||||||
|
color_purchase_button := 0xDCDCDC
|
||||||
|
tyres_overheating := false
|
||||||
|
tyreX := 150
|
||||||
|
tyreY := 365
|
||||||
|
purchaseX := 442
|
||||||
|
purchaseY := 356
|
||||||
|
acquiredX := 620
|
||||||
|
acquiredY := 268
|
||||||
|
|
||||||
|
; resolution parameters and pixel search locations
|
||||||
|
ps_win_width := 640
|
||||||
|
ps_win_height := 360
|
||||||
|
pix1x := 458
|
||||||
|
pix1y := 114
|
||||||
|
pix2x := 607
|
||||||
|
pix2y := 319
|
||||||
|
tolerance := 20
|
||||||
|
bm_delay := 100
|
||||||
|
box_size := 2
|
||||||
|
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
|
||||||
|
|
||||||
|
; Create a new controller controller
|
||||||
|
controller := new ViGEmDS4()
|
||||||
|
controller.SubscribeFeedback(Func("OnFeedback"))
|
||||||
|
|
||||||
|
OnFeedback(largeMotor, smallMotor, lightbarColor){
|
||||||
|
;OutputDebug % "AHK| Feedback received - LargeMotor: " largeMotor ", SmallMotor: " smallMotor ", LightBarColor: " lightbarColor
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
Gui, Add, Button, x15 y70 w70 default gGetColo_p, Stuck Leaderboard
|
||||||
|
Gui, Add, Button, x110 y70 w70 default gGetColo_g, Stuck Replay
|
||||||
|
Gui, Add, Button, x110 y100 w70 default gBuyCars, Buy Cars
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
Gui, Add, Radio, Group x15 y130 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
Gui, Add, Radio, x70 y130 altsubmit gPSystem, PS4
|
||||||
|
Gui, Add, Radio, x125 y130 altsubmit gPSystem, PS4 Pro
|
||||||
|
;Gui, Add, Radio, Group x15 y130 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
;Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
Gui, Add, Button, x70 y150 w70 default gReset, Reset
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text, x100 y90, Color 2 Delay
|
||||||
|
Gui, 2: Add, Edit, x100 y110 w40 vD, %color_2_delay%
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h185, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
BuyCars:
|
||||||
|
loop {
|
||||||
|
carIsAcquired := false
|
||||||
|
loop {
|
||||||
|
c1 := BitGrab(620, 268, box_size)
|
||||||
|
for i, c in c1
|
||||||
|
{
|
||||||
|
d1 := Distance(c, 0x7B7B7B)
|
||||||
|
if (d1 < tolerance ){
|
||||||
|
carIsAcquired := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (carIsAcquired)
|
||||||
|
break
|
||||||
|
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
loop {
|
||||||
|
inPurchaseMenu := false
|
||||||
|
c1 := BitGrab(purchaseX, purchaseY, box_size)
|
||||||
|
for i, c in c1
|
||||||
|
{
|
||||||
|
d1 := Distance(c, color_purchase_button)
|
||||||
|
if (d1 < tolerance ){
|
||||||
|
inPurchaseMenu := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (inPurchaseMenu)
|
||||||
|
break
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
loop, 4 {
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
carIsAcquired := false
|
||||||
|
Sleep, 1500
|
||||||
|
loop {
|
||||||
|
c1 := BitGrab(acquiredX, acquiredY, box_size)
|
||||||
|
for i, c in c1
|
||||||
|
{
|
||||||
|
d1 := Distance(c, color_acquired_flag)
|
||||||
|
if (d1 < tolerance ){
|
||||||
|
carIsAcquired := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (carIsAcquired)
|
||||||
|
break
|
||||||
|
|
||||||
|
gosub, PressX
|
||||||
|
}
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, color_2_delay, 2:, D
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, D, %color_2_delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
id := ""
|
||||||
|
SetKeyDelay, 10
|
||||||
|
Process, priority, , High
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
if (id = "")
|
||||||
|
return
|
||||||
|
gosub, PauseLoop
|
||||||
|
CoordMode, Pixel, Screen
|
||||||
|
CoordMode, ToolTip, Screen
|
||||||
|
sleep 1000
|
||||||
|
gosub, AFKLoop
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
gosub, PressX
|
||||||
|
DllCall("Sleep", "UInt", init_delay)
|
||||||
|
gosub, Race
|
||||||
|
if (tyres_overheating) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
gosub, Menu
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
controller.Buttons.Cross.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
CheckTyresOverheating:
|
||||||
|
tc := BitGrab(tyreX, tyreY, box_size)
|
||||||
|
for i, c in tc
|
||||||
|
{
|
||||||
|
td := Distance(c, color_tyre_overheat)
|
||||||
|
if (td < tolerance ){
|
||||||
|
tyres_overheating := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
RetryRace:
|
||||||
|
Gosub, PauseLoop
|
||||||
|
Sleep 500
|
||||||
|
tyres_overheating := false
|
||||||
|
controller.Buttons.Options.SetState(true)
|
||||||
|
Sleep 500
|
||||||
|
controller.Buttons.Options.SetState(false)
|
||||||
|
Sleep, 500
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Goto, AFKLoop
|
||||||
|
return
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
|
||||||
|
controller.Buttons.Cross.SetState(true)
|
||||||
|
controller.Buttons.RS.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", 8200)
|
||||||
|
SetTimer, CheckTyresOverheating, Off
|
||||||
|
SetTimer, CheckTyresOverheating, 1000
|
||||||
|
controller.Axes.LX.SetState(65)
|
||||||
|
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
loop {
|
||||||
|
DllCall("Sleep", "UInt", 500)
|
||||||
|
} until tyres_overheating || A_TickCount > tf
|
||||||
|
|
||||||
|
loop {
|
||||||
|
if (tyres_overheating) {
|
||||||
|
Goto, RetryRace
|
||||||
|
return
|
||||||
|
}
|
||||||
|
SetTimer, CheckTyresOverheating, Off
|
||||||
|
break_point := false
|
||||||
|
c1 := BitGrab(pix1x, pix1y, box_size)
|
||||||
|
for i, c in c1
|
||||||
|
{
|
||||||
|
d1 := Distance(c, color_check1)
|
||||||
|
if (d1 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Sleep, 500
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
controller.Buttons.RS.SetState(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu:
|
||||||
|
gosub, Menu_pixel
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_pixel:
|
||||||
|
loop {
|
||||||
|
break_point := false
|
||||||
|
c2 := BitGrab(pix2x, pix2y, box_size)
|
||||||
|
for i, c in c2
|
||||||
|
{
|
||||||
|
d2 := Distance(c, color_check2)
|
||||||
|
if (d2 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
gosub, PressX
|
||||||
|
sleep %color_2_delay%
|
||||||
|
sleep, %bm_delay%
|
||||||
|
}
|
||||||
|
;ToolTip, Found color 2, 100, 100, Screen
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
controller.Dpad.SetState(MenuDirect)
|
||||||
|
Sleep, 125
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1200
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
loop, 9{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1700
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
controller.Dpad.SetState(MenuDirect)
|
||||||
|
Sleep, 125
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 400
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
PixelTuning:
|
||||||
|
x_ratio := ps_win_width/640
|
||||||
|
y_ratio := ps_win_height/360
|
||||||
|
pix1x := Floor(pix1x*x_ratio)
|
||||||
|
pix1y := Floor(pix1y*y_ratio)
|
||||||
|
pix2x := Floor(pix2x*x_ratio)
|
||||||
|
pix2y := Floor(pix2y*y_ratio)
|
||||||
|
tyreX := Floor(tyreX*x_ratio)
|
||||||
|
tyreY := Floor(tyreY*y_ratio)
|
||||||
|
purchaseX := Floor(purchaseX*x_ratio)
|
||||||
|
purchaseY := Floor(purchaseY*y_ratio)
|
||||||
|
acquiredX := Floor(acquiredX*x_ratio)
|
||||||
|
acquiredY := Floor(purchaseY*y_ratio)
|
||||||
|
return
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
return
|
||||||
|
|
||||||
|
RPwind:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, -700, -400, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
|
||||||
|
{
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
|
||||||
|
w := NumGet(rect, 8, "int")
|
||||||
|
h := NumGet(rect, 12, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertARGB(ARGB, Convert := 0)
|
||||||
|
{
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
RGB += ARGB
|
||||||
|
RGB := RGB & 0x00FFFFFF
|
||||||
|
if (Convert)
|
||||||
|
RGB := (RGB & 0xFF000000) | ((RGB & 0xFF0000) >> 16) | (RGB & 0x00FF00) | ((RGB & 0x0000FF) << 16)
|
||||||
|
|
||||||
|
return RGB
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
MsgBox, This will test the number of Left/Right presses at the championship selection menu. `nTry this if you have not finished all cafe menus. `nPress OK to test
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
loop, %menu_loops% {
|
||||||
|
controller.Dpad.SetState(MenuDirect)
|
||||||
|
Sleep, 125
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
BitGrab(x, y, b)
|
||||||
|
{
|
||||||
|
HWND := WinExist("PS Remote Play")
|
||||||
|
pToken := Gdip_Startup()
|
||||||
|
pBitmap := Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
|
||||||
|
pixs := []
|
||||||
|
for i in range(-1*b, b+1){
|
||||||
|
for j in range(-1*b, b+1){
|
||||||
|
pixel := Gdip_GetPixel(pBitmap,x+i,y+j)
|
||||||
|
rgb := ConvertARGB( pixel )
|
||||||
|
pixs.Push(rgb)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdip_DisposeImage(pBitmap)
|
||||||
|
Gdip_Shutdown(pToken)
|
||||||
|
return pixs
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
{
|
||||||
|
WinGetPos,,, Width, Height, ahk_id %hwnd%
|
||||||
|
hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
|
||||||
|
RegExMatch(A_OsVersion, "\d+", Version)
|
||||||
|
PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
|
||||||
|
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
|
||||||
|
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
|
||||||
|
return pBitmap
|
||||||
|
}
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check1 := PixelColorSimple(pix1x, pix1y)
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check2 := PixelColorSimple(pix2x, pix2y)
|
||||||
|
return
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1){
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
}
|
||||||
|
if (SysCheck = 2){
|
||||||
|
ps_load_time1 := 41500
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 40000
|
||||||
|
}
|
||||||
|
if (SysCheck = 3){
|
||||||
|
ps_load_time1 := 37000
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 32000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
MenuSel:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (MenuCheck = 1){
|
||||||
|
menu_s := 1
|
||||||
|
}
|
||||||
|
if (MenuCheck = 2){
|
||||||
|
menu_s := 2
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Reset:
|
||||||
|
gosub, PauseLoop
|
||||||
|
Reload
|
||||||
|
Sleep 1000
|
||||||
|
return
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Buttons.RS.SetState(false)
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
return
|
||||||
|
|
||||||
|
range(start, stop:="", step:=1) {
|
||||||
|
static range := { _NewEnum: Func("_RangeNewEnum") }
|
||||||
|
if !step
|
||||||
|
throw "range(): Parameter 'step' must not be 0 or blank"
|
||||||
|
if (stop == "")
|
||||||
|
stop := start, start := 0
|
||||||
|
; Formula: r[i] := start + step*i ; r = range object, i = 0-based index
|
||||||
|
; For a postive 'step', the constraints are i >= 0 and r[i] < stop
|
||||||
|
; For a negative 'step', the constraints are i >= 0 and r[i] > stop
|
||||||
|
; No result is returned if r[0] does not meet the value constraint
|
||||||
|
if (step > 0 ? start < stop : start > stop) ;// start == start + step*0
|
||||||
|
return { base: range, start: start, stop: stop, step: step }
|
||||||
|
}
|
||||||
|
|
||||||
|
_RangeNewEnum(r) {
|
||||||
|
static enum := { "Next": Func("_RangeEnumNext") }
|
||||||
|
return { base: enum, r: r, i: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
_RangeEnumNext(enum, ByRef k, ByRef v:="") {
|
||||||
|
stop := enum.r.stop, step := enum.r.step
|
||||||
|
, k := enum.r.start + step*enum.i
|
||||||
|
if (ret := step > 0 ? k < stop : k > stop)
|
||||||
|
enum.i += 1
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
Binary file not shown.
@@ -0,0 +1,211 @@
|
|||||||
|
#include %A_LineFile%\..\CLR.ahk
|
||||||
|
|
||||||
|
; Static class, holds ViGEm Client instance
|
||||||
|
class ViGEmWrapper {
|
||||||
|
static asm := 0
|
||||||
|
static client := 0
|
||||||
|
|
||||||
|
Init(){
|
||||||
|
if (this.client == 0){
|
||||||
|
this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CreateInstance(cls){
|
||||||
|
return this.asm.CreateInstance(cls)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
; Base class for ViGEm "Targets" (Controller types - eg xb360 / ds4) to inherit from
|
||||||
|
class ViGEmTarget {
|
||||||
|
target := 0
|
||||||
|
helperClass := ""
|
||||||
|
controllerClass := ""
|
||||||
|
|
||||||
|
__New(){
|
||||||
|
;~ this.asm := CLR_LoadLibrary(A_LineFile "\..\ViGEmWrapper.dll")
|
||||||
|
ViGEmWrapper.Init()
|
||||||
|
this.Instance := ViGEmWrapper.CreateInstance(this.helperClass)
|
||||||
|
|
||||||
|
if (this.Instance.OkCheck() != "OK"){
|
||||||
|
msgbox ViGEmWrapper.dll failed to load!
|
||||||
|
ExitApp
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SendReport(){
|
||||||
|
this.Instance.SendReport()
|
||||||
|
}
|
||||||
|
|
||||||
|
SubscribeFeedback(callback){
|
||||||
|
this.Instance.SubscribeFeedback(callback)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; DS4 (DualShock 4 for Playstation 4)
|
||||||
|
class ViGEmDS4 extends ViGEmTarget {
|
||||||
|
helperClass := "ViGEmWrapper.Ds4"
|
||||||
|
__New(){
|
||||||
|
static buttons := {Square: 16, Cross: 32, Circle: 64, Triangle: 128, L1: 256, R1: 512, L2: 1024, R2: 2048
|
||||||
|
, Share: 4096, Options: 8192, LS: 16384, RS: 32768 }
|
||||||
|
static specialButtons := {Ps: 1, TouchPad: 2}
|
||||||
|
static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
|
||||||
|
|
||||||
|
this.Buttons := {}
|
||||||
|
for name, id in buttons {
|
||||||
|
this.Buttons[name] := new this._ButtonHelper(this, id)
|
||||||
|
}
|
||||||
|
for name, id in specialButtons {
|
||||||
|
this.Buttons[name] := new this._SpecialButtonHelper(this, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Axes := {}
|
||||||
|
for name, id in axes {
|
||||||
|
this.Axes[name] := new this._AxisHelper(this, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Dpad := new this._DpadHelper(this)
|
||||||
|
base.__New()
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ButtonHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetButtonState(this._Id, state)
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _SpecialButtonHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetSpecialButtonState(this._Id, state)
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AxisHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertAxis(state){
|
||||||
|
return round(state * 2.55)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DpadHelper {
|
||||||
|
__New(parent){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
static dPadDirections := {Up: 0, UpRight: 1, Right: 2, DownRight: 3, Down: 4, DownLeft: 5, Left: 6, UpLeft: 7, None: 8}
|
||||||
|
this._Parent.Instance.SetDpadState(dPadDirections[state])
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
; Xb360
|
||||||
|
class ViGEmXb360 extends ViGEmTarget {
|
||||||
|
helperClass := "ViGEmWrapper.Xb360"
|
||||||
|
__New(){
|
||||||
|
static buttons := {A: 4096, B: 8192, X: 16384, Y: 32768, LB: 256, RB: 512, LS: 64, RS: 128, Back: 32, Start: 16, Xbox: 1024}
|
||||||
|
static axes := {LX: 2, LY: 3, RX: 4, RY: 5, LT: 0, RT: 1}
|
||||||
|
|
||||||
|
this.Buttons := {}
|
||||||
|
for name, id in buttons {
|
||||||
|
this.Buttons[name] := new this._ButtonHelper(this, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Axes := {}
|
||||||
|
for name, id in axes {
|
||||||
|
this.Axes[name] := new this._AxisHelper(this, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Dpad := new this._DpadHelper(this)
|
||||||
|
|
||||||
|
base.__New()
|
||||||
|
}
|
||||||
|
|
||||||
|
class _ButtonHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._Id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetButtonState(this._Id, state)
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
return this._Parent
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _AxisHelper {
|
||||||
|
__New(parent, id){
|
||||||
|
this._Parent := parent
|
||||||
|
this._id := id
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
this._Parent.Instance.SetAxisState(this._Id, this.ConvertAxis(state))
|
||||||
|
this._Parent.Instance.SendReport()
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertAxis(state){
|
||||||
|
value := round((state * 655.36) - 32768)
|
||||||
|
if (value == 32768)
|
||||||
|
return 32767
|
||||||
|
return value
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class _DpadHelper {
|
||||||
|
_DpadStates := {1:0, 8:0, 2:0, 4:0} ; Up, Right, Down, Left
|
||||||
|
__New(parent){
|
||||||
|
this._Parent := parent
|
||||||
|
}
|
||||||
|
|
||||||
|
SetState(state){
|
||||||
|
static dpadDirections := { None: {1:0, 8:0, 2:0, 4:0}
|
||||||
|
, Up: {1:1, 8:0, 2:0, 4:0}
|
||||||
|
, UpRight: {1:1, 8:1, 2:0, 4:0}
|
||||||
|
, Right: {1:0, 8:1, 2:0, 4:0}
|
||||||
|
, DownRight: {1:0, 8:1, 2:1, 4:0}
|
||||||
|
, Down: {1:0, 8:0, 2:1, 4:0}
|
||||||
|
, DownLeft: {1:0, 8:0, 2:1, 4:1}
|
||||||
|
, Left: {1:0, 8:0, 2:0, 4:1}
|
||||||
|
, UpLeft: {1:1, 8:0, 2:0, 4:1}}
|
||||||
|
newStates := dpadDirections[state]
|
||||||
|
for id, newState in newStates {
|
||||||
|
oldState := this._DpadStates[id]
|
||||||
|
if (oldState != newState){
|
||||||
|
this._DpadStates[id] := newState
|
||||||
|
this._Parent.Instance.SetButtonState(id, newState)
|
||||||
|
}
|
||||||
|
this._Parent.SendReport()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,151 @@
|
|||||||
|
; ==========================================================
|
||||||
|
; .NET Framework Interop
|
||||||
|
; https://autohotkey.com/boards/viewtopic.php?t=4633
|
||||||
|
; ==========================================================
|
||||||
|
;
|
||||||
|
; Author: Lexikos
|
||||||
|
; Version: 1.2
|
||||||
|
; Requires: AutoHotkey_L v1.0.96+
|
||||||
|
;
|
||||||
|
|
||||||
|
CLR_LoadLibrary(AssemblyName, AppDomain=0)
|
||||||
|
{
|
||||||
|
if !AppDomain
|
||||||
|
AppDomain := CLR_GetDefaultDomain()
|
||||||
|
e := ComObjError(0)
|
||||||
|
Loop 1 {
|
||||||
|
if assembly := AppDomain.Load_2(AssemblyName)
|
||||||
|
break
|
||||||
|
static null := ComObject(13,0)
|
||||||
|
args := ComObjArray(0xC, 1), args[0] := AssemblyName
|
||||||
|
typeofAssembly := AppDomain.GetType().Assembly.GetType()
|
||||||
|
if assembly := typeofAssembly.InvokeMember_3("LoadWithPartialName", 0x158, null, null, args)
|
||||||
|
break
|
||||||
|
if assembly := typeofAssembly.InvokeMember_3("LoadFrom", 0x158, null, null, args)
|
||||||
|
break
|
||||||
|
}
|
||||||
|
ComObjError(e)
|
||||||
|
return assembly
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_CreateObject(Assembly, TypeName, Args*)
|
||||||
|
{
|
||||||
|
if !(argCount := Args.MaxIndex())
|
||||||
|
return Assembly.CreateInstance_2(TypeName, true)
|
||||||
|
|
||||||
|
vargs := ComObjArray(0xC, argCount)
|
||||||
|
Loop % argCount
|
||||||
|
vargs[A_Index-1] := Args[A_Index]
|
||||||
|
|
||||||
|
static Array_Empty := ComObjArray(0xC,0), null := ComObject(13,0)
|
||||||
|
|
||||||
|
return Assembly.CreateInstance_3(TypeName, true, 0, null, vargs, null, Array_Empty)
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_CompileC#(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
|
||||||
|
{
|
||||||
|
return CLR_CompileAssembly(Code, References, "System", "Microsoft.CSharp.CSharpCodeProvider", AppDomain, FileName, CompilerOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_CompileVB(Code, References="", AppDomain=0, FileName="", CompilerOptions="")
|
||||||
|
{
|
||||||
|
return CLR_CompileAssembly(Code, References, "System", "Microsoft.VisualBasic.VBCodeProvider", AppDomain, FileName, CompilerOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_StartDomain(ByRef AppDomain, BaseDirectory="")
|
||||||
|
{
|
||||||
|
static null := ComObject(13,0)
|
||||||
|
args := ComObjArray(0xC, 5), args[0] := "", args[2] := BaseDirectory, args[4] := ComObject(0xB,false)
|
||||||
|
AppDomain := CLR_GetDefaultDomain().GetType().InvokeMember_3("CreateDomain", 0x158, null, null, args)
|
||||||
|
return A_LastError >= 0
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_StopDomain(ByRef AppDomain)
|
||||||
|
{ ; ICorRuntimeHost::UnloadDomain
|
||||||
|
DllCall("SetLastError", "uint", hr := DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+20*A_PtrSize), "ptr", RtHst, "ptr", ComObjValue(AppDomain))), AppDomain := ""
|
||||||
|
return hr >= 0
|
||||||
|
}
|
||||||
|
|
||||||
|
; NOTE: IT IS NOT NECESSARY TO CALL THIS FUNCTION unless you need to load a specific version.
|
||||||
|
CLR_Start(Version="") ; returns ICorRuntimeHost*
|
||||||
|
{
|
||||||
|
static RtHst := 0
|
||||||
|
; The simple method gives no control over versioning, and seems to load .NET v2 even when v4 is present:
|
||||||
|
; return RtHst ? RtHst : (RtHst:=COM_CreateObject("CLRMetaData.CorRuntimeHost","{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}"), DllCall(NumGet(NumGet(RtHst+0)+40),"uint",RtHst))
|
||||||
|
if RtHst
|
||||||
|
return RtHst
|
||||||
|
EnvGet SystemRoot, SystemRoot
|
||||||
|
if Version =
|
||||||
|
Loop % SystemRoot "\Microsoft.NET\Framework" (A_PtrSize=8?"64":"") "\*", 2
|
||||||
|
if (FileExist(A_LoopFileFullPath "\mscorlib.dll") && A_LoopFileName > Version)
|
||||||
|
Version := A_LoopFileName
|
||||||
|
if DllCall("mscoree\CorBindToRuntimeEx", "wstr", Version, "ptr", 0, "uint", 0
|
||||||
|
, "ptr", CLR_GUID(CLSID_CorRuntimeHost, "{CB2F6723-AB3A-11D2-9C40-00C04FA30A3E}")
|
||||||
|
, "ptr", CLR_GUID(IID_ICorRuntimeHost, "{CB2F6722-AB3A-11D2-9C40-00C04FA30A3E}")
|
||||||
|
, "ptr*", RtHst) >= 0
|
||||||
|
DllCall(NumGet(NumGet(RtHst+0)+10*A_PtrSize), "ptr", RtHst) ; Start
|
||||||
|
return RtHst
|
||||||
|
}
|
||||||
|
|
||||||
|
;
|
||||||
|
; INTERNAL FUNCTIONS
|
||||||
|
;
|
||||||
|
|
||||||
|
CLR_GetDefaultDomain()
|
||||||
|
{
|
||||||
|
static defaultDomain := 0
|
||||||
|
if !defaultDomain
|
||||||
|
{ ; ICorRuntimeHost::GetDefaultDomain
|
||||||
|
if DllCall(NumGet(NumGet(0+RtHst:=CLR_Start())+13*A_PtrSize), "ptr", RtHst, "ptr*", p:=0) >= 0
|
||||||
|
defaultDomain := ComObject(p), ObjRelease(p)
|
||||||
|
}
|
||||||
|
return defaultDomain
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_CompileAssembly(Code, References, ProviderAssembly, ProviderType, AppDomain=0, FileName="", CompilerOptions="")
|
||||||
|
{
|
||||||
|
if !AppDomain
|
||||||
|
AppDomain := CLR_GetDefaultDomain()
|
||||||
|
|
||||||
|
if !(asmProvider := CLR_LoadLibrary(ProviderAssembly, AppDomain))
|
||||||
|
|| !(codeProvider := asmProvider.CreateInstance(ProviderType))
|
||||||
|
|| !(codeCompiler := codeProvider.CreateCompiler())
|
||||||
|
return 0
|
||||||
|
|
||||||
|
if !(asmSystem := (ProviderAssembly="System") ? asmProvider : CLR_LoadLibrary("System", AppDomain))
|
||||||
|
return 0
|
||||||
|
|
||||||
|
; Convert | delimited list of references into an array.
|
||||||
|
StringSplit, Refs, References, |, %A_Space%%A_Tab%
|
||||||
|
aRefs := ComObjArray(8, Refs0)
|
||||||
|
Loop % Refs0
|
||||||
|
aRefs[A_Index-1] := Refs%A_Index%
|
||||||
|
|
||||||
|
; Set parameters for compiler.
|
||||||
|
prms := CLR_CreateObject(asmSystem, "System.CodeDom.Compiler.CompilerParameters", aRefs)
|
||||||
|
, prms.OutputAssembly := FileName
|
||||||
|
, prms.GenerateInMemory := FileName=""
|
||||||
|
, prms.GenerateExecutable := SubStr(FileName,-3)=".exe"
|
||||||
|
, prms.CompilerOptions := CompilerOptions
|
||||||
|
, prms.IncludeDebugInformation := true
|
||||||
|
|
||||||
|
; Compile!
|
||||||
|
compilerRes := codeCompiler.CompileAssemblyFromSource(prms, Code)
|
||||||
|
|
||||||
|
if error_count := (errors := compilerRes.Errors).Count
|
||||||
|
{
|
||||||
|
error_text := ""
|
||||||
|
Loop % error_count
|
||||||
|
error_text .= ((e := errors.Item[A_Index-1]).IsWarning ? "Warning " : "Error ") . e.ErrorNumber " on line " e.Line ": " e.ErrorText "`n`n"
|
||||||
|
MsgBox, 16, Compilation Failed, %error_text%
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
; Success. Return Assembly object or path.
|
||||||
|
return compilerRes[FileName="" ? "CompiledAssembly" : "PathToAssembly"]
|
||||||
|
}
|
||||||
|
|
||||||
|
CLR_GUID(ByRef GUID, sGUID)
|
||||||
|
{
|
||||||
|
VarSetCapacity(GUID, 16, 0)
|
||||||
|
return DllCall("ole32\CLSIDFromString", "wstr", sGUID, "ptr", &GUID) >= 0 ? &GUID : ""
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,173 @@
|
|||||||
|
|
||||||
|
/**********************************************
|
||||||
|
* Controller methods for simplicity *
|
||||||
|
***********************************************/
|
||||||
|
*/
|
||||||
|
|
||||||
|
GoTo EndControllerFunctionsDef
|
||||||
|
|
||||||
|
;;;;;;;;;;;; Turning functions
|
||||||
|
;;;;;;;;;;;; For holding the stick in a specific position for a period of time
|
||||||
|
;;;;;;;;;;;; Note no other button may be pressed or released when these functions are ran
|
||||||
|
|
||||||
|
; Set the time you want to turn for in miliseconds and how hard (50, 100), 100 being the most, 50 being neutral
|
||||||
|
Turn_Right(sleept, inten){
|
||||||
|
t := sleept
|
||||||
|
controller.Axes.LX.SetState(inten)
|
||||||
|
gosub, Turn
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Set the time you want to turn for in miliseconds and how hard (0, 50), 0 being the most
|
||||||
|
Turn_Left(sleept, inten){
|
||||||
|
t := sleept
|
||||||
|
controller.Axes.LX.SetState(inten)
|
||||||
|
gosub, Turn
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
}
|
||||||
|
|
||||||
|
;;;;;;;;;;;; Simple button press functions
|
||||||
|
;;;;;;;;;;;; You can pass a delay amount or leave it blank
|
||||||
|
;;;;;;;;;;;; Longer delays hold the button longer
|
||||||
|
|
||||||
|
; Press X button
|
||||||
|
Press_X(delay:=200){
|
||||||
|
controller.Buttons.Cross.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
; Press O button
|
||||||
|
Press_O(delay:=200){
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
; Press Triangle button
|
||||||
|
Press_Triangle(delay:=200){
|
||||||
|
controller.Buttons.Triangle.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
controller.Buttons.Triangle.SetState(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
; Press Square button
|
||||||
|
Press_Square(delay:=200){
|
||||||
|
controller.Buttons.Square.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
controller.Buttons.Square.SetState(false)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
; Press Right on D-pad
|
||||||
|
Press_Right(delay:=200){
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
; Press Left on D-pad
|
||||||
|
Press_Left(delay:=200){
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
; Press Up on D-pad
|
||||||
|
Press_Up(delay:=200){
|
||||||
|
controller.Dpad.SetState("Up")
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
; Press Down on D-pad
|
||||||
|
Press_Down(delay:=200){
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
;;;;;;;;;;; Other functions specific to GT7
|
||||||
|
|
||||||
|
; Turn on nitrous
|
||||||
|
Nitrous_On(){
|
||||||
|
controller.Buttons.RS.SetState(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Turn off nitrous
|
||||||
|
Nitrous_Off(){
|
||||||
|
controller.Buttons.RS.SetState(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Accelerate
|
||||||
|
Accelerate(power:=100) {
|
||||||
|
if (power < 0) {
|
||||||
|
power:=0
|
||||||
|
}
|
||||||
|
if (power > 0) {
|
||||||
|
controller.Buttons.R2.SetState(true)
|
||||||
|
}
|
||||||
|
controller.Axes.RT.SetState(power)
|
||||||
|
if (power = 0) {
|
||||||
|
controller.Buttons.R2.SetState(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ResetControllerState() {
|
||||||
|
controller.Axes.LT.SetState(0)
|
||||||
|
controller.Buttons.L2.SetState(false)
|
||||||
|
controller.Axes.RT.SetState(0)
|
||||||
|
controller.Buttons.R2.SetState(false)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
controller.Axes.LY.SetState(50)
|
||||||
|
controller.Axes.RX.SetState(50)
|
||||||
|
controller.Axes.RY.SetState(50)
|
||||||
|
controller.Button.LS.SetState(false)
|
||||||
|
controller.Button.RS.SetState(false)
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
controller.Buttons.Square.SetState(false)
|
||||||
|
controller.Buttons.Triangle.SetState(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
Turn:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
loop {
|
||||||
|
Sleep(100)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
controller.Buttons.Cross.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
PressO:
|
||||||
|
; Just for menuing, does not hold O down
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
; For turning
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 50
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
EndControllerFunctionsDef:
|
||||||
@@ -0,0 +1,129 @@
|
|||||||
|
/**********************************************
|
||||||
|
* Only place functions here, no sub routines *
|
||||||
|
***********************************************/
|
||||||
|
|
||||||
|
|
||||||
|
; Grabs the colors of the pixels (x-b, y-b) to (x+b, y+b)
|
||||||
|
; returns the array of colors
|
||||||
|
*/
|
||||||
|
|
||||||
|
BitGrab(x, y, b)
|
||||||
|
{
|
||||||
|
HWND := WinExist("PS Remote Play")
|
||||||
|
pToken := Gdip_Startup()
|
||||||
|
pBitmap := Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
|
||||||
|
pixs := []
|
||||||
|
for i in range(-1*b, b+1){
|
||||||
|
for j in range(-1*b, b+1){
|
||||||
|
pixel := Gdip_GetPixel(pBitmap,x+i,y+j)
|
||||||
|
rgb := ConvertARGB( pixel )
|
||||||
|
pixs.Push(rgb)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdip_DisposeImage(pBitmap)
|
||||||
|
Gdip_Shutdown(pToken)
|
||||||
|
return pixs
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
{
|
||||||
|
WinGetPos,,, Width, Height, ahk_id %hwnd%
|
||||||
|
hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
|
||||||
|
RegExMatch(A_OsVersion, "\d+", Version)
|
||||||
|
PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
|
||||||
|
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
|
||||||
|
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
|
||||||
|
return pBitmap
|
||||||
|
}
|
||||||
|
|
||||||
|
range(start, stop:="", step:=1) {
|
||||||
|
static range := { _NewEnum: Func("_RangeNewEnum") }
|
||||||
|
if !step
|
||||||
|
throw "range(): Parameter 'step' must not be 0 or blank"
|
||||||
|
if (stop == "")
|
||||||
|
stop := start, start := 0
|
||||||
|
; Formula: r[i] := start + step*i ; r = range object, i = 0-based index
|
||||||
|
; For a postive 'step', the constraints are i >= 0 and r[i] < stop
|
||||||
|
; For a negative 'step', the constraints are i >= 0 and r[i] > stop
|
||||||
|
; No result is returned if r[0] does not meet the value constraint
|
||||||
|
if (step > 0 ? start < stop : start > stop) ;// start == start + step*0
|
||||||
|
return { base: range, start: start, stop: stop, step: step }
|
||||||
|
}
|
||||||
|
|
||||||
|
_RangeNewEnum(r) {
|
||||||
|
static enum := { "Next": Func("_RangeEnumNext") }
|
||||||
|
return { base: enum, r: r, i: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
_RangeEnumNext(enum, ByRef k, ByRef v:="") {
|
||||||
|
stop := enum.r.stop, step := enum.r.step
|
||||||
|
, k := enum.r.start + step*enum.i
|
||||||
|
if (ret := step > 0 ? k < stop : k > stop)
|
||||||
|
enum.i += 1
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Sleep(ms=1)
|
||||||
|
{
|
||||||
|
global timeBeginPeriodHasAlreadyBeenCalled
|
||||||
|
if (timeBeginPeriodHasAlreadyBeenCalled != 1)
|
||||||
|
{
|
||||||
|
DllCall("Winmm.dll\timeBeginPeriod", UInt, 1)
|
||||||
|
timeBeginPeriodHasAlreadyBeenCalled := 1
|
||||||
|
}
|
||||||
|
|
||||||
|
DllCall("Sleep", UInt, ms)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
|
||||||
|
{
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
|
||||||
|
w := NumGet(rect, 8, "int")
|
||||||
|
h := NumGet(rect, 12, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertARGB(ARGB, Convert := 0)
|
||||||
|
{
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
RGB += ARGB
|
||||||
|
RGB := RGB & 0x00FFFFFF
|
||||||
|
if (Convert)
|
||||||
|
RGB := (RGB & 0xFF000000) | ((RGB & 0xFF0000) >> 16) | (RGB & 0x00FF00) | ((RGB & 0x0000FF) << 16)
|
||||||
|
|
||||||
|
return RGB
|
||||||
|
}
|
||||||
@@ -0,0 +1,69 @@
|
|||||||
|
GoTo EndChampionshipMenuingDef
|
||||||
|
|
||||||
|
Menu:
|
||||||
|
;ToolTip, Menuing, 100, 100, Screen
|
||||||
|
loop {
|
||||||
|
break_point := false
|
||||||
|
c2 := BitGrab(pix2x, pix2y, box_size)
|
||||||
|
for i, c in c2
|
||||||
|
{
|
||||||
|
d2 := Distance(c, color_check2)
|
||||||
|
if (d2 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
Press_X()
|
||||||
|
sleep %color_2_delay%
|
||||||
|
sleep, %bm_delay%
|
||||||
|
}
|
||||||
|
ResetControllerState()
|
||||||
|
;ToolTip, Found color 2, 100, 100, Screen
|
||||||
|
Sleep, 200
|
||||||
|
Press_O()
|
||||||
|
Sleep, 200
|
||||||
|
Press_Right()
|
||||||
|
Sleep, 500
|
||||||
|
Press_X()
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
Press_X()
|
||||||
|
Sleep, 1000
|
||||||
|
Press_O()
|
||||||
|
loop, 2 {
|
||||||
|
Press_X()
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
;Conduct Maintenance here.
|
||||||
|
CheckForOilChange := Mod(A_Index, 29)
|
||||||
|
CheckForMaintenance := Mod(A_Index, 107)
|
||||||
|
ifEqual, CheckForOilChange, 0
|
||||||
|
{
|
||||||
|
gosub, DoOilChange
|
||||||
|
}
|
||||||
|
|
||||||
|
ifEqual, CheckForMaintenance, 0
|
||||||
|
{
|
||||||
|
gosub, DoMaintenance
|
||||||
|
}
|
||||||
|
|
||||||
|
Press_Down()
|
||||||
|
;Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
controller.Dpad.SetState(MenuDirect)
|
||||||
|
Sleep, 60
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 60
|
||||||
|
}
|
||||||
|
Press_X() ; Choose Pan-American
|
||||||
|
Sleep, 100 ; load Pan-American menu
|
||||||
|
Press_X() ; push join
|
||||||
|
Sleep, 1000 ; to compensate ps_load_time3
|
||||||
|
Sleep, %ps_load_time3% ; Loadtime Pan-American
|
||||||
|
Press_X() ; Confirm race 1
|
||||||
|
Sleep, 500 ; Load race 1 menu, Start will be pushed by race script.
|
||||||
|
return
|
||||||
|
|
||||||
|
EndChampionshipMenuingDef:
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
GoTo EndCheckTyresDef
|
||||||
|
|
||||||
|
CheckTyresOverheating:
|
||||||
|
tc := BitGrab(tyreX, tyreY, box_size)
|
||||||
|
for i, c in tc
|
||||||
|
{
|
||||||
|
td := Distance(c, color_tyre_overheat)
|
||||||
|
if (td < tolerance ){
|
||||||
|
tyres_overheating := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
RetryRace:
|
||||||
|
Gosub, PauseLoop
|
||||||
|
Sleep 500
|
||||||
|
tyres_overheating := false
|
||||||
|
controller.Buttons.Options.SetState(true)
|
||||||
|
Sleep 200
|
||||||
|
controller.Buttons.Options.SetState(false)
|
||||||
|
Sleep, 500
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Goto, AFKLoop
|
||||||
|
return
|
||||||
|
|
||||||
|
EndCheckTyresDef:
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
GoTo EndMaintenceDef
|
||||||
|
|
||||||
|
;This will do only an oil change. will leave user at race menu to resume.
|
||||||
|
GtAutoNav:
|
||||||
|
return
|
||||||
|
|
||||||
|
DoOilChange:
|
||||||
|
Sleep, 1000
|
||||||
|
Press_O()
|
||||||
|
Sleep, 2800
|
||||||
|
loop, 2 {
|
||||||
|
Press_Right(140)
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
Press_Down()
|
||||||
|
Sleep, 200
|
||||||
|
|
||||||
|
loop, 2 {
|
||||||
|
Press_X()
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
Sleep, 2000
|
||||||
|
Press_Down(140)
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
Press_X()
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
Press_X()
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
Press_O()
|
||||||
|
Sleep, 200
|
||||||
|
Sleep, 3000
|
||||||
|
Press_Up(140)
|
||||||
|
Sleep, 200
|
||||||
|
Press_Left()
|
||||||
|
Sleep, 500
|
||||||
|
Press_Left()
|
||||||
|
Sleep, 500
|
||||||
|
Press_X()
|
||||||
|
Sleep, 4800
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
;This will do complete maintenance on the car including oil, engine and body. will leave user at race menu to resume.
|
||||||
|
DoMaintenance:
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 2800
|
||||||
|
loop, 2 {
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
Sleep, 2000
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 8500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
Sleep, 3000
|
||||||
|
controller.Dpad.SetState("Up")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 4800
|
||||||
|
return
|
||||||
|
|
||||||
|
EndMaintenceDef:
|
||||||
@@ -0,0 +1,291 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
#Include Lib\Gdip.ahk
|
||||||
|
#Include Lib\AHK-ViGEm-Bus.ahk
|
||||||
|
#Include Lib\__utility__.ahk
|
||||||
|
#Include Lib\__controller_functions__.ahk
|
||||||
|
#Include Race.ahk
|
||||||
|
#Include Mod\Maintenance.ahk
|
||||||
|
#Include Mod\ChampionshipMenuing.ahk
|
||||||
|
|
||||||
|
|
||||||
|
hModule := DllCall("LoadLibrary", "Str", A_LineFile "\..\Lib\SuperSleep.dll", "Ptr")
|
||||||
|
SuperSleep := DllCall("GetProcAddress", "Ptr", DllCall("GetModuleHandle", "Str", A_LineFile "\..\Lib\SuperSleep.dll", "Ptr"), "AStr", "super_sleep", "Ptr")
|
||||||
|
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
; RUF pink 0x583375
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
Global t := 220000
|
||||||
|
intensity := 230
|
||||||
|
delay := 300
|
||||||
|
init_delay := 10000
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
box_size := 3
|
||||||
|
color_check1 := 0xBBE044
|
||||||
|
color_check2 := 0xBBE044
|
||||||
|
color_2_delay := 400
|
||||||
|
|
||||||
|
color_tyre_overheat := 0xD42304
|
||||||
|
tyres_overheating := false
|
||||||
|
tyreX := 166
|
||||||
|
tyreY := 364
|
||||||
|
|
||||||
|
; resolution parameters and pixel search locations
|
||||||
|
ps_win_width := 640
|
||||||
|
ps_win_height := 360
|
||||||
|
pix1x := 458
|
||||||
|
pix1y := 114
|
||||||
|
pix2x := 607
|
||||||
|
pix2y := 319
|
||||||
|
tolerance := 20
|
||||||
|
bm_delay := 100
|
||||||
|
box_size := 2
|
||||||
|
|
||||||
|
ps_load_time1 := 12000
|
||||||
|
ps_load_time2 := 6000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
|
||||||
|
; Create a new controller controller
|
||||||
|
Global controller := new ViGEmDS4()
|
||||||
|
controller.SubscribeFeedback(Func("OnFeedback"))
|
||||||
|
|
||||||
|
OnFeedback(largeMotor, smallMotor, lightbarColor){
|
||||||
|
;OutputDebug % "AHK| Feedback received - LargeMotor: " largeMotor ", SmallMotor: " smallMotor ", LightBarColor: " lightbarColor
|
||||||
|
}
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
Gui, Add, Button, x15 y70 w70 default gGetColo_p, Stuck Leaderboard
|
||||||
|
Gui, Add, Button, x110 y70 w70 default gGetColo_g, Stuck Replay
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
Gui, Add, Radio, Group x15 y115 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
Gui, Add, Radio, x70 y115 altsubmit gPSystem, PS4
|
||||||
|
Gui, Add, Radio, x125 y115 altsubmit gPSystem, PS4 Pro
|
||||||
|
;Gui, Add, Radio, Group x15 y130 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
;Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
Gui, Add, Button, x70 y135 w70 default gReset, Reset
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
Gui, 2: Add, Text, x100 y90, Color 2 Delay
|
||||||
|
Gui, 2: Add, Edit, x100 y110 w40 vD, %color_2_delay%
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h170, GT7 Pan American AFK
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
GuiControlGet, color_2_delay, 2:, D
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t := 220000
|
||||||
|
intensity := 230
|
||||||
|
delay := 300
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
GuiControl, 2:, D, %color_2_delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
id := ""
|
||||||
|
SetKeyDelay, 10
|
||||||
|
Process, priority, , High
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
if (id = "")
|
||||||
|
return
|
||||||
|
gosub, PauseLoop
|
||||||
|
CoordMode, Pixel, Screen
|
||||||
|
CoordMode, ToolTip, Screen
|
||||||
|
sleep 1000
|
||||||
|
gosub, AFKLoop
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
; ---------- AFK Loop -----------------
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
CheckForOilChange := Mod(A_Index, 29)
|
||||||
|
CheckForMaintenance := Mod(A_Index, 107)
|
||||||
|
if (CheckForOilChange = 0) {
|
||||||
|
OCremain := 0
|
||||||
|
}
|
||||||
|
if (CheckForOilChange > 0) {
|
||||||
|
OCremain := 30 - CheckForOilChange
|
||||||
|
SetFormat, IntegerFast, d
|
||||||
|
}
|
||||||
|
if (CheckForMaintenance = 0) {
|
||||||
|
EOremain := 0
|
||||||
|
}
|
||||||
|
if (CheckForMaintenance > 0) {
|
||||||
|
EOremain := 108 - CheckForMaintenance
|
||||||
|
SetFormat, IntegerFast, d
|
||||||
|
}
|
||||||
|
ToolTip, Oil: %OCremain% race(s) remaining`nEngine: %EOremain% race(s) remaining, 250, 45, Screen
|
||||||
|
Press_X()
|
||||||
|
DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version
|
||||||
|
gosub, Race
|
||||||
|
/*
|
||||||
|
if (tyres_overheating) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
gosub, Menu
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
PixelTuning:
|
||||||
|
x_ratio := ps_win_width/640
|
||||||
|
y_ratio := ps_win_height/360
|
||||||
|
pix1x := Floor(pix1x*x_ratio)
|
||||||
|
pix1y := Floor(pix1y*y_ratio)
|
||||||
|
pix2x := Floor(pix2x*x_ratio)
|
||||||
|
pix2y := Floor(pix2y*y_ratio)
|
||||||
|
tyreX := Floor(tyreX*x_ratio)
|
||||||
|
tyreY := Floor(tyreY*y_ratio)
|
||||||
|
return
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
;MsgBox, This will test the number of Left/Right presses at the championship selection menu. `nTry this if you have not finished all cafe menus. `nPress OK to test
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
loop, %menu_loops% {
|
||||||
|
controller.Dpad.SetState(MenuDirect)
|
||||||
|
Sleep, 125
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check1 := PixelColorSimple(pix1x, pix1y)
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check2 := PixelColorSimple(pix2x, pix2y)
|
||||||
|
return
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1){
|
||||||
|
ps_load_time1 := 12000
|
||||||
|
ps_load_time2 := 6000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
}
|
||||||
|
if (SysCheck = 2){
|
||||||
|
ps_load_time1 := 37000
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 32000
|
||||||
|
}
|
||||||
|
if (SysCheck = 3){
|
||||||
|
ps_load_time1 := 37000
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 32000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Reset:
|
||||||
|
gosub, PauseLoop
|
||||||
|
Reload
|
||||||
|
Sleep 1000
|
||||||
|
return
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
^Esc::ExitApp
|
||||||
|
|
||||||
|
/*
|
||||||
|
Pink RUF color"
|
||||||
|
which is the standart first one to buy if you want to buy car manufactur color (for me german GT7 i think its same for everyone)
|
||||||
|
0xFA559F
|
||||||
|
|
||||||
|
i have put that into Color check 1 and 2 works since 5 cycles - so maybe put them in with like (not tested)
|
||||||
|
(i think the first option that gets shown to buy a new color is the easiest to explain for people to buy except for colors the car exists in anyways (venom green)
|
||||||
|
here is the Hex Code for Porsche "Sternrubin" Ruby or Starruby depending on language:
|
||||||
|
0xBA3A64
|
||||||
|
*/
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
GoTo EndRaceDef
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
Accelerate()
|
||||||
|
Nitrous_On()
|
||||||
|
DllCall("Sleep", "UInt", 7600)
|
||||||
|
;SetTimer, CheckTyresOverheating, 1000
|
||||||
|
|
||||||
|
/*
|
||||||
|
Screen: 100, 237 (less often used)
|
||||||
|
Window: -817, 181 (default)
|
||||||
|
Client: -825, 130 (recommended)
|
||||||
|
Color: 814DA5 (Red=81 Green=4D Blue=A5)
|
||||||
|
|
||||||
|
E78883
|
||||||
|
*/
|
||||||
|
/* Lap 1 total laptime 34000ms
|
||||||
|
*/
|
||||||
|
Sleep(1000)
|
||||||
|
Turn_Right(2800, 75) /* before turn 1, to avoid queue of cars */
|
||||||
|
Sleep(1000)
|
||||||
|
Turn_Left(2000,0) /* turn 1 */
|
||||||
|
Sleep(1000)
|
||||||
|
Turn_Right(2000, 75)
|
||||||
|
Turn_Right(8800, 65)
|
||||||
|
Sleep(1000)
|
||||||
|
Turn_Left(1500,0) /* turn 2 */
|
||||||
|
Sleep(1000)
|
||||||
|
Turn_Right(3000, 65)
|
||||||
|
Sleep(1000)
|
||||||
|
Nitrous_Off()
|
||||||
|
Turn_Left(2000,0) /* turn 3 */
|
||||||
|
Nitrous_On()
|
||||||
|
Sleep(900)
|
||||||
|
Turn_Right(3700, 65)
|
||||||
|
|
||||||
|
;lap 2
|
||||||
|
|
||||||
|
Turn_Right(7400, 65)
|
||||||
|
Sleep(800)
|
||||||
|
Turn_Left(950,0) /* turn 1 */
|
||||||
|
Sleep(1000)
|
||||||
|
Turn_Right(2000, 70)
|
||||||
|
Turn_Right(8800, 65)
|
||||||
|
Sleep(900)
|
||||||
|
Turn_Left(1450,0) /* turn 2 */
|
||||||
|
Sleep(1000)
|
||||||
|
Turn_Right(3000, 65)
|
||||||
|
Sleep(1000)
|
||||||
|
Nitrous_Off()
|
||||||
|
Turn_Left(2000,0) /* turn 3 */
|
||||||
|
Nitrous_On()
|
||||||
|
Sleep(900)
|
||||||
|
Turn_Right(3500, 65)
|
||||||
|
|
||||||
|
;lap 3
|
||||||
|
|
||||||
|
Turn_Right(7400, 65)
|
||||||
|
Sleep(1000)
|
||||||
|
Turn_Left(1000,0) /* turn 1 */
|
||||||
|
Sleep(1000)
|
||||||
|
Turn_Right(2000, 75)
|
||||||
|
Turn_Right(8800, 65)
|
||||||
|
Sleep(500)
|
||||||
|
Turn_Left(1000,0) /* turn 2 */
|
||||||
|
Sleep(500)
|
||||||
|
Turn_Right(3000, 65)
|
||||||
|
Sleep(1000)
|
||||||
|
Nitrous_Off()
|
||||||
|
Turn_Left(2000,0) /* turn 3 */
|
||||||
|
Nitrous_On()
|
||||||
|
Sleep(1000)
|
||||||
|
Turn_Right(3400, 65)
|
||||||
|
|
||||||
|
; Rest of the race just keep turning right
|
||||||
|
controller.Axes.LX.SetState(67)
|
||||||
|
|
||||||
|
;lap 4 No left turns anymore; total control time = 35050
|
||||||
|
/*
|
||||||
|
Turn_Right(7600, 65)
|
||||||
|
Turn_Right(300, 60)
|
||||||
|
Sleep(1800)
|
||||||
|
;Turn_Left(1000,0) /* turn 1 */
|
||||||
|
Sleep(1000)
|
||||||
|
Turn_Right(2000, 75)
|
||||||
|
Turn_Right(9000, 65)
|
||||||
|
Sleep(1500)
|
||||||
|
;Turn_Left(1450,0) /* turn 2 */
|
||||||
|
Sleep(1400)
|
||||||
|
;Turn_Right(3000, 65)
|
||||||
|
Sleep(2000)
|
||||||
|
;Nitrous_Off()
|
||||||
|
;Turn_Left(2000,0) /* turn 3 */
|
||||||
|
;Nitrous_On()
|
||||||
|
Sleep(2000)
|
||||||
|
Turn_Right(3400, 65)
|
||||||
|
|
||||||
|
; Lap 5
|
||||||
|
|
||||||
|
Turn_Right(7700, 65)
|
||||||
|
Turn_Right(300, 60)
|
||||||
|
Sleep(1800)
|
||||||
|
;Turn_Left(1000,0) /* turn 1 */
|
||||||
|
Sleep(1000)
|
||||||
|
Turn_Right(2000, 75)
|
||||||
|
Turn_Right(9000, 65)
|
||||||
|
Sleep(1500)
|
||||||
|
;Turn_Left(1450,0) /* turn 2 */
|
||||||
|
Sleep(1400)
|
||||||
|
Turn_Right(3000, 65)
|
||||||
|
Sleep(2000)
|
||||||
|
;Nitrous_Off()
|
||||||
|
;Turn_Left(2000,0) /* turn 3 */
|
||||||
|
;Nitrous_On()
|
||||||
|
Sleep(2000)
|
||||||
|
Turn_Right(3600, 65)
|
||||||
|
|
||||||
|
; Lap 6
|
||||||
|
Turn_Right(7700, 65)
|
||||||
|
Turn_Right(500, 60)
|
||||||
|
Sleep(1800)
|
||||||
|
;Turn_Left(1000,0) /* turn 1 */
|
||||||
|
Sleep(1000)
|
||||||
|
Turn_Right(2000, 75)
|
||||||
|
Turn_Right(9000, 65)
|
||||||
|
Sleep(1500)
|
||||||
|
;Turn_Left(1450,0) /* turn 2 */
|
||||||
|
Sleep(1500)
|
||||||
|
Turn_Right(3000, 65)
|
||||||
|
Sleep(2000)
|
||||||
|
;Nitrous_Off()
|
||||||
|
;Turn_Left(2000,0) /* turn 3 */
|
||||||
|
;Nitrous_On()
|
||||||
|
Sleep(2000)
|
||||||
|
Turn_Right(5000, 65)
|
||||||
|
Turn_Right(7000, 60)
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
; 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
|
||||||
|
Screen: 218, 359 (less often used)
|
||||||
|
Window: 222, 357 (default)
|
||||||
|
Client: 214, 326 (recommended)
|
||||||
|
Color: 3F1757 (Red=3F Green=17 Blue=57)
|
||||||
|
|
||||||
|
Screen: 247, 65 (less often used)
|
||||||
|
Window: -129, -376 (default)
|
||||||
|
Client: -129, -376 (recommended)
|
||||||
|
Color: FD3C37 (Red=FD Green=3C Blue=37)
|
||||||
|
|
||||||
|
Screen: 210, 64 (less often used)
|
||||||
|
Window: 210, 64 (default)
|
||||||
|
Client: 202, 33 (recommended)
|
||||||
|
Color: 5091E9 (Red=50 Green=91 Blue=E9)
|
||||||
|
|
||||||
|
Screen: 261, 39 (less often used)
|
||||||
|
Window: 261, 39 (default)
|
||||||
|
Client: 253, 8 (recommended)
|
||||||
|
Color: A774A9 (Red=A7 Green=74 Blue=A9)
|
||||||
|
|
||||||
|
Screen: 263, 74 (less often used)
|
||||||
|
Window: 263, 74 (default)
|
||||||
|
Client: 255, 43 (recommended)
|
||||||
|
Color: FF3632 (Red=FF Green=36 Blue=32)
|
||||||
|
*/
|
||||||
|
return
|
||||||
|
|
||||||
|
EndRaceDef:
|
||||||
Binary file not shown.
@@ -0,0 +1,347 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
t := 220000
|
||||||
|
intensity := 220
|
||||||
|
delay := 160
|
||||||
|
|
||||||
|
color_check1 := 0x3E1858
|
||||||
|
color_check2 := 0x48A267
|
||||||
|
c1_alt := false
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
Gui, Add, Button, x15 y70 w70 default gGetColo_p, ColorP1
|
||||||
|
Gui, Add, Button, x110 y70 w70 default gGetColo_g, ColorP2
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h120, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t = 220000
|
||||||
|
intensity = 220
|
||||||
|
delay := 140
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
id := ""
|
||||||
|
SetKeyDelay, 10
|
||||||
|
Process, priority, , High
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
if (id = "")
|
||||||
|
return
|
||||||
|
gosub, PauseLoop
|
||||||
|
CoordMode, Pixel, Screen
|
||||||
|
CoordMode, ToolTip, Screen
|
||||||
|
sleep 1000
|
||||||
|
gosub, AFKLoop
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
;gosub, Menu
|
||||||
|
gosub, PressX
|
||||||
|
DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version
|
||||||
|
gosub, Race
|
||||||
|
gosub, Menu
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
; For turning
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 8200)
|
||||||
|
gosub TurnRight
|
||||||
|
/*
|
||||||
|
; 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
|
||||||
|
Screen: 218, 359 (less often used)
|
||||||
|
Window: 222, 357 (default)
|
||||||
|
Client: 214, 326 (recommended)
|
||||||
|
Color: 3F1757 (Red=3F Green=17 Blue=57)
|
||||||
|
*/
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, 216, 357, 220, 361, %color_check1%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 140
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
/* haven't gotten this to work, for color picking when pixel search acting dumb
|
||||||
|
if (c1_alt ) {
|
||||||
|
loop, 10{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
While c1_alt
|
||||||
|
Sleep 1000
|
||||||
|
*/
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Menu:
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, 340, 361, 344, 365, %color_check2%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
gosub, PressX
|
||||||
|
sleep 300
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 14000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, 6 {
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1200
|
||||||
|
}
|
||||||
|
Sleep, 8400
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
RPwind:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, -700, -400, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check1 := PixelColorSimple(218, 359)
|
||||||
|
;MsgBox, At the screen with [Replay] [Next Race], Press ColorP2
|
||||||
|
c1_alt := true
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check2 := PixelColorSimple(343, 363)
|
||||||
|
c1_alt := false
|
||||||
|
return
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
@@ -0,0 +1,350 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
t := 220000
|
||||||
|
intensity := 220
|
||||||
|
delay := 160
|
||||||
|
|
||||||
|
color_check1 := 0x3E1858
|
||||||
|
color_check2 := 0x48A267
|
||||||
|
c1_alt := false
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
Gui, Add, Button, x15 y70 w70 default gGetColo_p, ColorP1
|
||||||
|
Gui, Add, Button, x110 y70 w70 default gGetColo_g, ColorP2
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h120, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t = 220000
|
||||||
|
intensity = 220
|
||||||
|
delay := 140
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
id := ""
|
||||||
|
SetKeyDelay, 10
|
||||||
|
Process, priority, , High
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
if (id = "")
|
||||||
|
return
|
||||||
|
gosub, PauseLoop
|
||||||
|
CoordMode, Pixel, Screen
|
||||||
|
CoordMode, ToolTip, Screen
|
||||||
|
sleep 1000
|
||||||
|
gosub, AFKLoop
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
;gosub, Menu
|
||||||
|
gosub, PressX
|
||||||
|
DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version
|
||||||
|
gosub, Race
|
||||||
|
gosub, Menu
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
; For turning
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 8200)
|
||||||
|
gosub TurnRight
|
||||||
|
/*
|
||||||
|
; 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
|
||||||
|
Screen: 218, 359 (less often used)
|
||||||
|
Window: 222, 357 (default)
|
||||||
|
Client: 214, 326 (recommended)
|
||||||
|
Color: 3F1757 (Red=3F Green=17 Blue=57)
|
||||||
|
*/
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, 216, 357, 220, 361, %color_check1%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 140
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
/* haven't gotten this to work, for color picking when pixel search acting dumb
|
||||||
|
if (c1_alt ) {
|
||||||
|
loop, 10{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
While c1_alt
|
||||||
|
Sleep 1000
|
||||||
|
*/
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Menu:
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, 340, 361, 344, 365, %color_check2%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
gosub, PressX
|
||||||
|
sleep 300
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 14000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, 6 {
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1200
|
||||||
|
}
|
||||||
|
Sleep, 8400
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
RPwind:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, -700, -400, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check1 := PixelColorSimple(218, 359)
|
||||||
|
;MsgBox, At the screen with [Replay] [Next Race], Press ColorP2
|
||||||
|
c1_alt := true
|
||||||
|
MsgBox, Put this in for color_check1 %color_check1%
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check2 := PixelColorSimple(343, 363)
|
||||||
|
c1_alt := false
|
||||||
|
MsgBox, Put this in for color_check2 %color_check2%
|
||||||
|
return
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
@@ -0,0 +1,448 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
t := 220000
|
||||||
|
intensity := 220
|
||||||
|
delay := 160
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
color_check1 := 0x3E1858
|
||||||
|
color_check2 := 0x43c36a
|
||||||
|
c1_alt := false
|
||||||
|
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
Gui, Add, Button, x15 y70 w70 default gGetColo_p, ColorP1
|
||||||
|
Gui, Add, Button, x110 y70 w70 default gGetColo_g, ColorP2
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
Gui, Add, Radio, Group x15 y100 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
Gui, Add, Radio, x70 y100 altsubmit gPSystem, PS4
|
||||||
|
Gui, Add, Radio, Group x15 y120 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h150, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t = 220000
|
||||||
|
intensity = 220
|
||||||
|
delay := 140
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
id := ""
|
||||||
|
SetKeyDelay, 10
|
||||||
|
Process, priority, , High
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
if (id = "")
|
||||||
|
return
|
||||||
|
gosub, PauseLoop
|
||||||
|
CoordMode, Pixel, Screen
|
||||||
|
CoordMode, ToolTip, Screen
|
||||||
|
sleep 1000
|
||||||
|
gosub, AFKLoop
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
;gosub, Menu
|
||||||
|
gosub, PressX
|
||||||
|
DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version
|
||||||
|
gosub, Race
|
||||||
|
gosub, Menu
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
; For turning
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 8200)
|
||||||
|
gosub TurnRight
|
||||||
|
/*
|
||||||
|
; 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
|
||||||
|
Screen: 218, 359 (less often used)
|
||||||
|
Window: 222, 357 (default)
|
||||||
|
Client: 214, 326 (recommended)
|
||||||
|
Color: 3F1757 (Red=3F Green=17 Blue=57)
|
||||||
|
*/
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, 216, 357, 220, 361, %color_check1%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 140
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
/* haven't gotten this to work, for color picking when pixel search acting dumb
|
||||||
|
if (c1_alt ) {
|
||||||
|
loop, 10{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
}
|
||||||
|
While c1_alt
|
||||||
|
Sleep 1000
|
||||||
|
*/
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu:
|
||||||
|
if (menu_s = 1){
|
||||||
|
gosub, Menu_pixel
|
||||||
|
}
|
||||||
|
if (menu_s = 2){
|
||||||
|
gosub, Menu_time
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_pixel:
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, 340, 360, 344, 364, %color_check2%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
gosub, PressX
|
||||||
|
sleep 300
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1200
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_time:
|
||||||
|
loop, 9{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1700
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
RPwind:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, -700, -400, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check1 := PixelColorSimple(218, 359)
|
||||||
|
;MsgBox, At the screen with [Replay] [Next Race], Press ColorP2
|
||||||
|
c1_alt := true
|
||||||
|
MsgBox, Put this in for color_check1 %color_check1%
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check2 := PixelColorSimple(342, 362)
|
||||||
|
c1_alt := false
|
||||||
|
MsgBox, Put this in for color_check2 %color_check2%
|
||||||
|
return
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1){
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
}
|
||||||
|
if (SysCheck = 2){
|
||||||
|
ps_load_time1 := 41500
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 40000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
MenuSel:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (MenuCheck = 1){
|
||||||
|
menu_s := 1
|
||||||
|
}
|
||||||
|
if (MenuCheck = 2){
|
||||||
|
menu_s := 2
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
@@ -0,0 +1,486 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
t := 220000
|
||||||
|
intensity := 220
|
||||||
|
delay := 160
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
color_check1 := 0x3E1858
|
||||||
|
color_check2 := 0x43c36a
|
||||||
|
c1_alt := false
|
||||||
|
color_2_delay := 300
|
||||||
|
|
||||||
|
|
||||||
|
; resolution parameters and pixel search locations
|
||||||
|
ps_win_width := 640
|
||||||
|
ps_win_height := 360
|
||||||
|
pix1x := 218
|
||||||
|
pix1y := 358
|
||||||
|
pix2x := 342
|
||||||
|
pix2y := 362
|
||||||
|
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
Gui, Add, Button, x15 y70 w70 default gGetColo_p, ColorP1
|
||||||
|
Gui, Add, Button, x110 y70 w70 default gGetColo_g, ColorP2
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
Gui, Add, Radio, Group x15 y100 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
Gui, Add, Radio, x70 y100 altsubmit gPSystem, PS4
|
||||||
|
Gui, Add, Radio, Group x15 y120 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
Gui, 2: Add, Text, x100 y90, Color 2 Delay
|
||||||
|
Gui, 2: Add, Edit, x100 y110 w40 vD, %color_2_delay%
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h150, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
GuiControlGet, color_2_delay, 2:, D
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t = 220000
|
||||||
|
intensity = 220
|
||||||
|
delay := 140
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
GuiControl, 2:, D, %color_2_delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
id := ""
|
||||||
|
SetKeyDelay, 10
|
||||||
|
Process, priority, , High
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
if (id = "")
|
||||||
|
return
|
||||||
|
gosub, PauseLoop
|
||||||
|
CoordMode, Pixel, Screen
|
||||||
|
CoordMode, ToolTip, Screen
|
||||||
|
sleep 1000
|
||||||
|
gosub, AFKLoop
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
;gosub, Menu
|
||||||
|
gosub, PressX
|
||||||
|
DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version
|
||||||
|
gosub, Race
|
||||||
|
gosub, Menu
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PressO:
|
||||||
|
; Just for menuing, does not hold O down
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
; For turning
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 8200)
|
||||||
|
gosub TurnRight
|
||||||
|
/*
|
||||||
|
; 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
|
||||||
|
Screen: 218, 359 (less often used)
|
||||||
|
Window: 222, 357 (default)
|
||||||
|
Client: 214, 326 (recommended)
|
||||||
|
Color: 3F1757 (Red=3F Green=17 Blue=57)
|
||||||
|
*/
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, %pix1x%-2, %pix1y%-2, %pix1x%+2, %pix1y%+2, %color_check1%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 140
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu:
|
||||||
|
if (menu_s = 1){
|
||||||
|
gosub, Menu_pixel
|
||||||
|
}
|
||||||
|
if (menu_s = 2){
|
||||||
|
gosub, Menu_time
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_pixel:
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, %pix2x%-2, %pix2y%-2, %pix2x%+2, %pix2y%+2, %color_check2%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
gosub, PressX
|
||||||
|
sleep %color_2_delay%
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1200
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_time:
|
||||||
|
loop, 9{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1700
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
PixelTuning:
|
||||||
|
x_ratio := ps_win_width/640
|
||||||
|
y_ratio := ps_win_height/360
|
||||||
|
pix1x := Floor(218*x_ratio)
|
||||||
|
pix1y := Floor(358*y_ratio)
|
||||||
|
pix2x := Floor(342*x_ratio)
|
||||||
|
pix2y := Floor(362*y_ratio)
|
||||||
|
return
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
return
|
||||||
|
|
||||||
|
RPwind:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, -700, -400, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
|
||||||
|
{
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
|
||||||
|
w := NumGet(rect, 8, "int")
|
||||||
|
h := NumGet(rect, 12, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
|
||||||
|
/* this section was used to test resoltuion specs
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
MsgBox, Width %ps_win_width% Height %ps_win_height% pix1 %pix1x%
|
||||||
|
*/
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check1 := PixelColorSimple(218, 359)
|
||||||
|
;MsgBox, At the screen with [Replay] [Next Race], Press ColorP2
|
||||||
|
c1_alt := true
|
||||||
|
MsgBox, Put this in for color_check1 %color_check1%
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check2 := PixelColorSimple(342, 362)
|
||||||
|
c1_alt := false
|
||||||
|
MsgBox, Put this in for color_check2 %color_check2%
|
||||||
|
return
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1){
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
}
|
||||||
|
if (SysCheck = 2){
|
||||||
|
ps_load_time1 := 41500
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 40000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
MenuSel:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (MenuCheck = 1){
|
||||||
|
menu_s := 1
|
||||||
|
}
|
||||||
|
if (MenuCheck = 2){
|
||||||
|
menu_s := 2
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
@@ -0,0 +1,672 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
#Include Lib\Gdip.ahk
|
||||||
|
;#include Lib\AHK-ViGEm-Bus.ahk
|
||||||
|
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
; RUF pink 0x583375
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
t := 220000
|
||||||
|
intensity := 230
|
||||||
|
delay := 160
|
||||||
|
init_delay := 10000
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
box_size := 3
|
||||||
|
color_check1 := 0xBBE044
|
||||||
|
color_check2 := 0xBBE044
|
||||||
|
color_2_delay := 1500
|
||||||
|
|
||||||
|
color_tyre_overheat := 0xD42304
|
||||||
|
tyres_overheating := false
|
||||||
|
tyreX := 166
|
||||||
|
tyreY := 364
|
||||||
|
|
||||||
|
; resolution parameters and pixel search locations
|
||||||
|
ps_win_width := 640
|
||||||
|
ps_win_height := 360
|
||||||
|
pix1x := 458
|
||||||
|
pix1y := 114
|
||||||
|
pix2x := 607
|
||||||
|
pix2y := 319
|
||||||
|
tolerance := 20
|
||||||
|
bm_delay := 100
|
||||||
|
box_size := 2
|
||||||
|
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
|
||||||
|
/*
|
||||||
|
; Create a new controller controller
|
||||||
|
controller := new ViGEmDS4()
|
||||||
|
controller.SubscribeFeedback(Func("OnFeedback"))
|
||||||
|
|
||||||
|
OnFeedback(largeMotor, smallMotor, lightbarColor){
|
||||||
|
;OutputDebug % "AHK| Feedback received - LargeMotor: " largeMotor ", SmallMotor: " smallMotor ", LightBarColor: " lightbarColor
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
Gui, Add, Button, x15 y70 w70 default gGetColo_p, Stuck Leaderboard
|
||||||
|
Gui, Add, Button, x110 y70 w70 default gGetColo_g, Stuck Replay
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
Gui, Add, Radio, Group x15 y115 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
Gui, Add, Radio, x70 y115 altsubmit gPSystem, PS4
|
||||||
|
;Gui, Add, Radio, Group x15 y130 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
;Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
Gui, Add, Button, x70 y135 w70 default gReset, Reset
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
Gui, 2: Add, Text, x100 y90, Color 2 Delay
|
||||||
|
Gui, 2: Add, Edit, x100 y110 w40 vD, %color_2_delay%
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h170, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
GuiControlGet, color_2_delay, 2:, D
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t = 220000
|
||||||
|
intensity = 220
|
||||||
|
delay := 140
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
GuiControl, 2:, D, %color_2_delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
id := ""
|
||||||
|
SetKeyDelay, 10
|
||||||
|
Process, priority, , High
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
if (id = "")
|
||||||
|
return
|
||||||
|
gosub, PauseLoop
|
||||||
|
CoordMode, Pixel, Screen
|
||||||
|
CoordMode, ToolTip, Screen
|
||||||
|
sleep 1000
|
||||||
|
gosub, AFKLoop
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
;gosub, Menu
|
||||||
|
gosub, PressX
|
||||||
|
DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version
|
||||||
|
gosub, Race
|
||||||
|
/*
|
||||||
|
if (tyres_overheating) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
gosub, Menu
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PressO:
|
||||||
|
; Just for menuing, does not hold O down
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
; For turning
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until tyres_overheating || A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until tyres_overheating || A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
CheckTyresOverheating:
|
||||||
|
tc := BitGrab(tyreX, tyreY, box_size)
|
||||||
|
for i, c in tc
|
||||||
|
{
|
||||||
|
td := Distance(c, color_tyre_overheat)
|
||||||
|
if (td < tolerance ){
|
||||||
|
tyres_overheating := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
RetryRace:
|
||||||
|
Gosub, PauseLoop
|
||||||
|
Sleep 500
|
||||||
|
tyres_overheating := false
|
||||||
|
controller.Buttons.Options.SetState(true)
|
||||||
|
Sleep 500
|
||||||
|
controller.Buttons.Options.SetState(false)
|
||||||
|
Sleep, 500
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Goto, AFKLoop
|
||||||
|
return
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 8200)
|
||||||
|
;SetTimer, CheckTyresOverheating, 1000
|
||||||
|
gosub TurnRight
|
||||||
|
/*
|
||||||
|
; 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
|
||||||
|
Screen: 218, 359 (less often used)
|
||||||
|
Window: 222, 357 (default)
|
||||||
|
Client: 214, 326 (recommended)
|
||||||
|
Color: 3F1757 (Red=3F Green=17 Blue=57)
|
||||||
|
|
||||||
|
Screen: 247, 65 (less often used)
|
||||||
|
Window: -129, -376 (default)
|
||||||
|
Client: -129, -376 (recommended)
|
||||||
|
Color: FD3C37 (Red=FD Green=3C Blue=37)
|
||||||
|
|
||||||
|
Screen: 210, 64 (less often used)
|
||||||
|
Window: 210, 64 (default)
|
||||||
|
Client: 202, 33 (recommended)
|
||||||
|
Color: 5091E9 (Red=50 Green=91 Blue=E9)
|
||||||
|
|
||||||
|
Screen: 261, 39 (less often used)
|
||||||
|
Window: 261, 39 (default)
|
||||||
|
Client: 253, 8 (recommended)
|
||||||
|
Color: A774A9 (Red=A7 Green=74 Blue=A9)
|
||||||
|
|
||||||
|
Screen: 263, 74 (less often used)
|
||||||
|
Window: 263, 74 (default)
|
||||||
|
Client: 255, 43 (recommended)
|
||||||
|
Color: FF3632 (Red=FF Green=36 Blue=32)
|
||||||
|
*/
|
||||||
|
loop {
|
||||||
|
/*
|
||||||
|
if (tyres_overheating) {
|
||||||
|
Goto, RetryRace
|
||||||
|
return
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
break_point := false
|
||||||
|
c1 := BitGrab(pix1x, pix1y, box_size)
|
||||||
|
for i, c in c1
|
||||||
|
{
|
||||||
|
d1 := Distance(c, color_check1)
|
||||||
|
if (d1 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 140
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
/*
|
||||||
|
PixelSearch, x, y, pix1x-10, pix1y-10, pix1x+10, pix1y+10, %color_check1%, 32, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 140
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
;ToolTip, Found color 1, 100, 100, Screen
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu:
|
||||||
|
if (menu_s = 1){
|
||||||
|
gosub, Menu_pixel
|
||||||
|
}
|
||||||
|
if (menu_s = 2){
|
||||||
|
gosub, Menu_time
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_pixel:
|
||||||
|
;ToolTip, Menuing, 100, 100, Screen
|
||||||
|
loop {
|
||||||
|
break_point := false
|
||||||
|
c2 := BitGrab(pix2x, pix2y, box_size)
|
||||||
|
for i, c in c2
|
||||||
|
{
|
||||||
|
d2 := Distance(c, color_check2)
|
||||||
|
if (d2 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
gosub, PressX
|
||||||
|
sleep %color_2_delay%
|
||||||
|
sleep, %bm_delay%
|
||||||
|
}
|
||||||
|
;ToolTip, Found color 2, 100, 100, Screen
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1200
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_time:
|
||||||
|
loop, 9{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1700
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 100
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 400
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
PixelTuning:
|
||||||
|
x_ratio := ps_win_width/640
|
||||||
|
y_ratio := ps_win_height/360
|
||||||
|
pix1x := Floor(pix1x*x_ratio)
|
||||||
|
pix1y := Floor(pix1y*y_ratio)
|
||||||
|
pix2x := Floor(pix2x*x_ratio)
|
||||||
|
pix2y := Floor(pix2y*y_ratio)
|
||||||
|
tyreX := Floor(tyreX*x_ratio)
|
||||||
|
tyreY := Floor(tyreY*y_ratio)
|
||||||
|
return
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
return
|
||||||
|
|
||||||
|
RPwind:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, -700, -400, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
|
||||||
|
{
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
|
||||||
|
w := NumGet(rect, 8, "int")
|
||||||
|
h := NumGet(rect, 12, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertARGB(ARGB, Convert := 0)
|
||||||
|
{
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
RGB += ARGB
|
||||||
|
RGB := RGB & 0x00FFFFFF
|
||||||
|
if (Convert)
|
||||||
|
RGB := (RGB & 0xFF000000) | ((RGB & 0xFF0000) >> 16) | (RGB & 0x00FF00) | ((RGB & 0x0000FF) << 16)
|
||||||
|
|
||||||
|
return RGB
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
MsgBox, This will test the number of Left/Right presses at the championship selection menu. `nTry this if you have not finished all cafe menus. `nPress OK to test
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/*this section was used to test resoltuion specs
|
||||||
|
|
||||||
|
/*
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
MsgBox, Width %ps_win_width% Height %ps_win_height% pix1 %pix1x%
|
||||||
|
*/
|
||||||
|
return
|
||||||
|
|
||||||
|
BitGrab(x, y, b)
|
||||||
|
{
|
||||||
|
HWND := WinExist("PS Remote Play")
|
||||||
|
pToken := Gdip_Startup()
|
||||||
|
pBitmap := Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
|
||||||
|
pixs := []
|
||||||
|
for i in range(-1*b, b+1){
|
||||||
|
for j in range(-1*b, b+1){
|
||||||
|
pixel := Gdip_GetPixel(pBitmap,x+i,y+j)
|
||||||
|
rgb := ConvertARGB( pixel )
|
||||||
|
pixs.Push(rgb)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdip_DisposeImage(pBitmap)
|
||||||
|
Gdip_Shutdown(pToken)
|
||||||
|
return pixs
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
{
|
||||||
|
WinGetPos,,, Width, Height, ahk_id %hwnd%
|
||||||
|
hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
|
||||||
|
RegExMatch(A_OsVersion, "\d+", Version)
|
||||||
|
PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
|
||||||
|
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
|
||||||
|
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
|
||||||
|
return pBitmap
|
||||||
|
}
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check1 := PixelColorSimple(pix1x, pix1y)
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check2 := PixelColorSimple(pix2x, pix2y)
|
||||||
|
return
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1){
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
}
|
||||||
|
if (SysCheck = 2){
|
||||||
|
ps_load_time1 := 41500
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 40000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
MenuSel:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (MenuCheck = 1){
|
||||||
|
menu_s := 1
|
||||||
|
}
|
||||||
|
if (MenuCheck = 2){
|
||||||
|
menu_s := 2s
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Reset:
|
||||||
|
gosub, PauseLoop
|
||||||
|
Reload
|
||||||
|
Sleep 1000
|
||||||
|
return
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
range(start, stop:="", step:=1) {
|
||||||
|
static range := { _NewEnum: Func("_RangeNewEnum") }
|
||||||
|
if !step
|
||||||
|
throw "range(): Parameter 'step' must not be 0 or blank"
|
||||||
|
if (stop == "")
|
||||||
|
stop := start, start := 0
|
||||||
|
; Formula: r[i] := start + step*i ; r = range object, i = 0-based index
|
||||||
|
; For a postive 'step', the constraints are i >= 0 and r[i] < stop
|
||||||
|
; For a negative 'step', the constraints are i >= 0 and r[i] > stop
|
||||||
|
; No result is returned if r[0] does not meet the value constraint
|
||||||
|
if (step > 0 ? start < stop : start > stop) ;// start == start + step*0
|
||||||
|
return { base: range, start: start, stop: stop, step: step }
|
||||||
|
}
|
||||||
|
|
||||||
|
_RangeNewEnum(r) {
|
||||||
|
static enum := { "Next": Func("_RangeEnumNext") }
|
||||||
|
return { base: enum, r: r, i: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
_RangeEnumNext(enum, ByRef k, ByRef v:="") {
|
||||||
|
stop := enum.r.stop, step := enum.r.step
|
||||||
|
, k := enum.r.start + step*enum.i
|
||||||
|
if (ret := step > 0 ? k < stop : k > stop)
|
||||||
|
enum.i += 1
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
|
|
||||||
|
/*
|
||||||
|
Pink RUF color"
|
||||||
|
which is the standart first one to buy if you want to buy car manufactur color (for me german GT7 i think its same for everyone)
|
||||||
|
0xFA559F
|
||||||
|
|
||||||
|
i have put that into Color check 1 and 2 works since 5 cycles - so maybe put them in with like (not tested)
|
||||||
|
(i think the first option that gets shown to buy a new color is the easiest to explain for people to buy except for colors the car exists in anyways (venom green)
|
||||||
|
here is the Hex Code for Porsche "Sternrubin" Ruby or Starruby depending on language:
|
||||||
|
0xBA3A64
|
||||||
|
*/
|
||||||
@@ -0,0 +1,788 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
#Include Lib\Gdip.ahk
|
||||||
|
#Include Lib\AHK-ViGEm-Bus.ahk
|
||||||
|
|
||||||
|
hModule := DllCall("LoadLibrary", "Str", A_LineFile "\..\Lib\SuperSleep.dll", "Ptr")
|
||||||
|
SuperSleep := DllCall("GetProcAddress", "Ptr", DllCall("GetModuleHandle", "Str", A_LineFile "\..\Lib\SuperSleep.dll", "Ptr"), "AStr", "super_sleep", "Ptr")
|
||||||
|
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
Global t := 220000
|
||||||
|
intensity := 230
|
||||||
|
delay := 300
|
||||||
|
init_delay := 10000
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
box_size := 3
|
||||||
|
color_check1 := 0xBBE044
|
||||||
|
color_check2 := 0xBBE044
|
||||||
|
color_2_delay := 500
|
||||||
|
|
||||||
|
color_tyre_overheat := 0xD42304
|
||||||
|
tyres_overheating := false
|
||||||
|
tyreX := 166
|
||||||
|
tyreY := 364
|
||||||
|
|
||||||
|
; resolution parameters and pixel search locations
|
||||||
|
ps_win_width := 640
|
||||||
|
ps_win_height := 360
|
||||||
|
pix1x := 458
|
||||||
|
pix1y := 114
|
||||||
|
pix2x := 607
|
||||||
|
pix2y := 319
|
||||||
|
tolerance := 20
|
||||||
|
bm_delay := 100
|
||||||
|
box_size := 2
|
||||||
|
|
||||||
|
ps_load_time1 := 12000
|
||||||
|
ps_load_time2 := 6000
|
||||||
|
ps_load_time3 := 9000
|
||||||
|
|
||||||
|
; Create a new controller controller
|
||||||
|
Global controller := new ViGEmDS4()
|
||||||
|
controller.SubscribeFeedback(Func("OnFeedback"))
|
||||||
|
|
||||||
|
OnFeedback(largeMotor, smallMotor, lightbarColor){
|
||||||
|
;OutputDebug % "AHK| Feedback received - LargeMotor: " largeMotor ", SmallMotor: " smallMotor ", LightBarColor: " lightbarColor
|
||||||
|
}
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
Gui, Add, Button, x15 y70 w70 default gGetColo_p, Stuck Leaderboard
|
||||||
|
Gui, Add, Button, x110 y70 w70 default gGetColo_g, Stuck Replay
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
Gui, Add, Radio, Group x15 y115 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
Gui, Add, Radio, x70 y115 altsubmit gPSystem, PS4
|
||||||
|
Gui, Add, Radio, x125 y115 altsubmit gPSystem, PS4 Pro
|
||||||
|
;Gui, Add, Radio, Group x15 y130 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
;Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
Gui, Add, Button, x70 y135 w70 default gReset, Reset
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
Gui, 2: Add, Text, x100 y90, Color 2 Delay
|
||||||
|
Gui, 2: Add, Edit, x100 y110 w40 vD, %color_2_delay%
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h170, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
GuiControlGet, color_2_delay, 2:, D
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t := 220000
|
||||||
|
intensity := 230
|
||||||
|
delay := 300
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
GuiControl, 2:, D, %color_2_delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
id := ""
|
||||||
|
SetKeyDelay, 10
|
||||||
|
Process, priority, , High
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
if (id = "")
|
||||||
|
return
|
||||||
|
gosub, PauseLoop
|
||||||
|
CoordMode, Pixel, Screen
|
||||||
|
CoordMode, ToolTip, Screen
|
||||||
|
sleep 1000
|
||||||
|
gosub, AFKLoop
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
gosub, ResetControllerState
|
||||||
|
gosub, PressX
|
||||||
|
gosub, Race
|
||||||
|
gosub, Menu_End_Race
|
||||||
|
gosub, Menu_Start_Race
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
controller.Buttons.Cross.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
PressO:
|
||||||
|
; Just for menuing, does not hold O down
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
; For turning
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 50
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
Sleep(100)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
Sleep(100)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
; Set the time you want to turn for in miliseconds and how hard (50, 100), 100 being the most, 50 being neutral
|
||||||
|
Turn_Right(sleept, inten){
|
||||||
|
t := sleept
|
||||||
|
controller.Axes.LX.SetState(inten)
|
||||||
|
gosub, TurnRight
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Set the time you want to turn for in miliseconds and how hard (0, 50), 0 being the most
|
||||||
|
Turn_Left(sleept, inten){
|
||||||
|
t := sleept
|
||||||
|
controller.Axes.LX.SetState(inten)
|
||||||
|
gosub, TurnLeft
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ResetControllerState:
|
||||||
|
controller.Axes.RT.SetState(0)
|
||||||
|
controller.Buttons.R2.SetState(false)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
controller.Axes.LY.SetState(50)
|
||||||
|
controller.Axes.RX.SetState(50)
|
||||||
|
controller.Axes.RY.SetState(50)
|
||||||
|
controller.Button.LS.SetState(false)
|
||||||
|
controller.Button.RS.SetState(false)
|
||||||
|
controller.Button.RT.SetState(false)
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
controller.Buttons.Square.SetState(false)
|
||||||
|
controller.Buttons.Triangle.SetState(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
;This will do only an oil change. will leave user at race menu to resume.
|
||||||
|
DoOilChange:
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 2800
|
||||||
|
loop, 2 {
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
Sleep, 2000
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
Sleep, 3000
|
||||||
|
controller.Dpad.SetState("Up")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 4800
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
;This will do complete maintenance on the car including oil, engine and body. will leave user at race menu to resume.
|
||||||
|
DoMaintenance:
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 2800
|
||||||
|
loop, 2 {
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
Sleep, 2000
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 8500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
Sleep, 3000
|
||||||
|
controller.Dpad.SetState("Up")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 4800
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Menu_Start_Race:
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 100
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 250
|
||||||
|
loop, %menu_loops% {
|
||||||
|
controller.Dpad.SetState(MenuDirect)
|
||||||
|
Sleep, 100
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 250
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
gosub, PressX
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
Tooltip
|
||||||
|
controller.Buttons.Cross.SetState(true)
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 17500
|
||||||
|
controller.Axes.LX.SetState(67)
|
||||||
|
|
||||||
|
CheckForOilChange := Mod(A_Index, 29)
|
||||||
|
CheckForMaintenance := Mod(A_Index, 107)
|
||||||
|
OCremain := 30 - CheckForOilChange
|
||||||
|
SetFormat, IntegerFast, d
|
||||||
|
EOremain := 108 - CheckForMaintenance
|
||||||
|
SetFormat, IntegerFast, d
|
||||||
|
ToolTip, Oil: %OCremain% lap(s) remaining`nEngine: %EOremain% lap(s) remaining, 250, 45, Screen
|
||||||
|
|
||||||
|
race_complete := false
|
||||||
|
SetTimer, RaceComplete, 225000
|
||||||
|
|
||||||
|
; Retry race if time is taking more than 5.5 mins
|
||||||
|
; (assume something went wrong with race)
|
||||||
|
SetTimer, RetryRace, 330000
|
||||||
|
|
||||||
|
loop {
|
||||||
|
|
||||||
|
;ToolTip, Racing, 100, 100, Screen
|
||||||
|
break_point := false
|
||||||
|
c1 := BitGrab(pix1x, pix1y, box_size)
|
||||||
|
for i, c in c1
|
||||||
|
{
|
||||||
|
d1 := Distance(c, color_check1)
|
||||||
|
if (d1 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
if (race_complete) {
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 50
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
ToolTip, Found color 1, 100, 100, Screen
|
||||||
|
SetTimer, RetryRace, off
|
||||||
|
gosub, ResetControllerState
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
RaceComplete:
|
||||||
|
race_complete := true
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Menu_End_Race:
|
||||||
|
ToolTip, Menuing, 100, 100, Screen
|
||||||
|
loop {
|
||||||
|
break_point := false
|
||||||
|
c2 := BitGrab(pix2x, pix2y, box_size)
|
||||||
|
for i, c in c2
|
||||||
|
{
|
||||||
|
d2 := Distance(c, color_check2)
|
||||||
|
if (d2 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
gosub, PressX
|
||||||
|
sleep, %color_2_delay%
|
||||||
|
}
|
||||||
|
ToolTip, Found color 2, 100, 100, Screen
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Tooltip
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
;Conduct Maintenance here.
|
||||||
|
ifEqual, CheckForOilChange, 0
|
||||||
|
{
|
||||||
|
gosub, DoOilChange
|
||||||
|
}
|
||||||
|
ifEqual, CheckForMaintenance, 0
|
||||||
|
{
|
||||||
|
gosub, DoMaintenance
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
RetryRace:
|
||||||
|
ToolTip, Retry Race, 100, 100, Screen
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
Gosub, ResetControllerState
|
||||||
|
Sleep 200
|
||||||
|
controller.Buttons.Options.SetState(true)
|
||||||
|
Sleep 200
|
||||||
|
controller.Buttons.Options.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
Goto, AFKLoop
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
|
||||||
|
PixelTuning:
|
||||||
|
x_ratio := ps_win_width/640
|
||||||
|
y_ratio := ps_win_height/360
|
||||||
|
pix1x := Floor(pix1x*x_ratio)
|
||||||
|
pix1y := Floor(pix1y*y_ratio)
|
||||||
|
pix2x := Floor(pix2x*x_ratio)
|
||||||
|
pix2y := Floor(pix2y*y_ratio)
|
||||||
|
tyreX := Floor(tyreX*x_ratio)
|
||||||
|
tyreY := Floor(tyreY*y_ratio)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
|
||||||
|
{
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
|
||||||
|
w := NumGet(rect, 8, "int")
|
||||||
|
h := NumGet(rect, 12, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertARGB(ARGB, Convert := 0)
|
||||||
|
{
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
RGB += ARGB
|
||||||
|
RGB := RGB & 0x00FFFFFF
|
||||||
|
if (Convert)
|
||||||
|
RGB := (RGB & 0xFF000000) | ((RGB & 0xFF0000) >> 16) | (RGB & 0x00FF00) | ((RGB & 0x0000FF) << 16)
|
||||||
|
|
||||||
|
return RGB
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
;MsgBox, This will test the number of Left/Right presses at the championship selection menu. `nTry this if you have not finished all cafe menus. `nPress OK to test
|
||||||
|
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
loop, %menu_loops% {
|
||||||
|
controller.Dpad.SetState(MenuDirect)
|
||||||
|
Sleep, 125
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*this section was used to test resoltuion specs
|
||||||
|
|
||||||
|
/*
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
MsgBox, Width %ps_win_width% Height %ps_win_height% pix1 %pix1x%
|
||||||
|
*/
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
BitGrab(x, y, b)
|
||||||
|
{
|
||||||
|
HWND := WinExist("PS Remote Play")
|
||||||
|
pToken := Gdip_Startup()
|
||||||
|
pBitmap := Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
|
||||||
|
pixs := []
|
||||||
|
for i in range(-1*b, b+1){
|
||||||
|
for j in range(-1*b, b+1){
|
||||||
|
pixel := Gdip_GetPixel(pBitmap,x+i,y+j)
|
||||||
|
rgb := ConvertARGB( pixel )
|
||||||
|
pixs.Push(rgb)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdip_DisposeImage(pBitmap)
|
||||||
|
Gdip_Shutdown(pToken)
|
||||||
|
return pixs
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
{
|
||||||
|
WinGetPos,,, Width, Height, ahk_id %hwnd%
|
||||||
|
hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
|
||||||
|
RegExMatch(A_OsVersion, "\d+", Version)
|
||||||
|
PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
|
||||||
|
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
|
||||||
|
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
|
||||||
|
return pBitmap
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check1 := PixelColorSimple(pix1x, pix1y)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check2 := PixelColorSimple(pix2x, pix2y)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1){
|
||||||
|
ps_load_time1 := 12000
|
||||||
|
ps_load_time2 := 6000
|
||||||
|
ps_load_time3 := 9000
|
||||||
|
}
|
||||||
|
if (SysCheck = 2){
|
||||||
|
ps_load_time1 := 37000
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 33000
|
||||||
|
}
|
||||||
|
if (SysCheck = 3){
|
||||||
|
ps_load_time1 := 37000
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 33000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
MenuSel:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (MenuCheck = 1){
|
||||||
|
menu_s := 1
|
||||||
|
}
|
||||||
|
if (MenuCheck = 2){
|
||||||
|
menu_s := 2
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Reset:
|
||||||
|
gosub, PauseLoop
|
||||||
|
Reload
|
||||||
|
Sleep 1000
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
range(start, stop:="", step:=1) {
|
||||||
|
static range := { _NewEnum: Func("_RangeNewEnum") }
|
||||||
|
if !step
|
||||||
|
throw "range(): Parameter 'step' must not be 0 or blank"
|
||||||
|
if (stop == "")
|
||||||
|
stop := start, start := 0
|
||||||
|
; Formula: r[i] := start + step*i ; r = range object, i = 0-based index
|
||||||
|
; For a postive 'step', the constraints are i >= 0 and r[i] < stop
|
||||||
|
; For a negative 'step', the constraints are i >= 0 and r[i] > stop
|
||||||
|
; No result is returned if r[0] does not meet the value constraint
|
||||||
|
if (step > 0 ? start < stop : start > stop) ;// start == start + step*0
|
||||||
|
return { base: range, start: start, stop: stop, step: step }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_RangeNewEnum(r) {
|
||||||
|
static enum := { "Next": Func("_RangeEnumNext") }
|
||||||
|
return { base: enum, r: r, i: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_RangeEnumNext(enum, ByRef k, ByRef v:="") {
|
||||||
|
stop := enum.r.stop, step := enum.r.step
|
||||||
|
, k := enum.r.start + step*enum.i
|
||||||
|
if (ret := step > 0 ? k < stop : k > stop)
|
||||||
|
enum.i += 1
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Sleep(ms=1)
|
||||||
|
{
|
||||||
|
global timeBeginPeriodHasAlreadyBeenCalled
|
||||||
|
if (timeBeginPeriodHasAlreadyBeenCalled != 1)
|
||||||
|
{
|
||||||
|
DllCall("Winmm.dll\timeBeginPeriod", UInt, 1)
|
||||||
|
timeBeginPeriodHasAlreadyBeenCalled := 1
|
||||||
|
}
|
||||||
|
DllCall("Sleep", UInt, ms)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
@@ -0,0 +1,787 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
#Include Lib\Gdip.ahk
|
||||||
|
#Include Lib\AHK-ViGEm-Bus.ahk
|
||||||
|
|
||||||
|
hModule := DllCall("LoadLibrary", "Str", A_LineFile "\..\Lib\SuperSleep.dll", "Ptr")
|
||||||
|
SuperSleep := DllCall("GetProcAddress", "Ptr", DllCall("GetModuleHandle", "Str", A_LineFile "\..\Lib\SuperSleep.dll", "Ptr"), "AStr", "super_sleep", "Ptr")
|
||||||
|
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
Global t := 220000
|
||||||
|
intensity := 230
|
||||||
|
delay := 300
|
||||||
|
init_delay := 10000
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
box_size := 3
|
||||||
|
color_check1 := 0xBBE044
|
||||||
|
color_check2 := 0xBBE044
|
||||||
|
color_2_delay := 500
|
||||||
|
|
||||||
|
color_tyre_overheat := 0xD42304
|
||||||
|
tyres_overheating := false
|
||||||
|
tyreX := 166
|
||||||
|
tyreY := 364
|
||||||
|
|
||||||
|
; resolution parameters and pixel search locations
|
||||||
|
ps_win_width := 640
|
||||||
|
ps_win_height := 360
|
||||||
|
pix1x := 458
|
||||||
|
pix1y := 114
|
||||||
|
pix2x := 607
|
||||||
|
pix2y := 319
|
||||||
|
tolerance := 20
|
||||||
|
bm_delay := 100
|
||||||
|
box_size := 2
|
||||||
|
|
||||||
|
ps_load_time1 := 12000
|
||||||
|
ps_load_time2 := 6000
|
||||||
|
ps_load_time3 := 9000
|
||||||
|
|
||||||
|
; Create a new controller controller
|
||||||
|
Global controller := new ViGEmDS4()
|
||||||
|
controller.SubscribeFeedback(Func("OnFeedback"))
|
||||||
|
|
||||||
|
OnFeedback(largeMotor, smallMotor, lightbarColor){
|
||||||
|
;OutputDebug % "AHK| Feedback received - LargeMotor: " largeMotor ", SmallMotor: " smallMotor ", LightBarColor: " lightbarColor
|
||||||
|
}
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
Gui, Add, Button, x15 y70 w70 default gGetColo_p, Stuck Leaderboard
|
||||||
|
Gui, Add, Button, x110 y70 w70 default gGetColo_g, Stuck Replay
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
Gui, Add, Radio, Group x15 y115 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
Gui, Add, Radio, x70 y115 altsubmit gPSystem, PS4
|
||||||
|
Gui, Add, Radio, x125 y115 altsubmit gPSystem, PS4 Pro
|
||||||
|
;Gui, Add, Radio, Group x15 y130 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
;Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
Gui, Add, Button, x70 y135 w70 default gReset, Reset
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
Gui, 2: Add, Text, x100 y90, Color 2 Delay
|
||||||
|
Gui, 2: Add, Edit, x100 y110 w40 vD, %color_2_delay%
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h170, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
GuiControlGet, color_2_delay, 2:, D
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t := 220000
|
||||||
|
intensity := 230
|
||||||
|
delay := 300
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
GuiControl, 2:, D, %color_2_delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
id := ""
|
||||||
|
SetKeyDelay, 10
|
||||||
|
Process, priority, , High
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
if (id = "")
|
||||||
|
return
|
||||||
|
gosub, PauseLoop
|
||||||
|
CoordMode, Pixel, Screen
|
||||||
|
CoordMode, ToolTip, Screen
|
||||||
|
sleep 1000
|
||||||
|
gosub, AFKLoop
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
gosub, ResetControllerState
|
||||||
|
gosub, PressX
|
||||||
|
gosub, Race
|
||||||
|
gosub, Menu_End_Race
|
||||||
|
gosub, Menu_Start_Race
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
controller.Buttons.Cross.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
PressO:
|
||||||
|
; Just for menuing, does not hold O down
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
; For turning
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 50
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
Sleep(100)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
Sleep(100)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
; Set the time you want to turn for in miliseconds and how hard (50, 100), 100 being the most, 50 being neutral
|
||||||
|
Turn_Right(sleept, inten){
|
||||||
|
t := sleept
|
||||||
|
controller.Axes.LX.SetState(inten)
|
||||||
|
gosub, TurnRight
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Set the time you want to turn for in miliseconds and how hard (0, 50), 0 being the most
|
||||||
|
Turn_Left(sleept, inten){
|
||||||
|
t := sleept
|
||||||
|
controller.Axes.LX.SetState(inten)
|
||||||
|
gosub, TurnLeft
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ResetControllerState:
|
||||||
|
controller.Axes.RT.SetState(0)
|
||||||
|
controller.Buttons.R2.SetState(false)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
controller.Axes.LY.SetState(50)
|
||||||
|
controller.Axes.RX.SetState(50)
|
||||||
|
controller.Axes.RY.SetState(50)
|
||||||
|
controller.Button.LS.SetState(false)
|
||||||
|
controller.Button.RS.SetState(false)
|
||||||
|
controller.Button.RT.SetState(false)
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
controller.Buttons.Square.SetState(false)
|
||||||
|
controller.Buttons.Triangle.SetState(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
;This will do only an oil change. will leave user at race menu to resume.
|
||||||
|
DoOilChange:
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 2800
|
||||||
|
loop, 2 {
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
Sleep, 2000
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
Sleep, 3000
|
||||||
|
controller.Dpad.SetState("Up")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 4800
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
;This will do complete maintenance on the car including oil, engine and body. will leave user at race menu to resume.
|
||||||
|
DoMaintenance:
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 2800
|
||||||
|
loop, 2 {
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
Sleep, 2000
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 8500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
Sleep, 3000
|
||||||
|
controller.Dpad.SetState("Up")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 4800
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Menu_Start_Race:
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 50
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 50
|
||||||
|
loop, %menu_loops% {
|
||||||
|
controller.Dpad.SetState(MenuDirect)
|
||||||
|
Sleep, 50
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 50
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
gosub, PressX
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
Tooltip
|
||||||
|
controller.Buttons.Cross.SetState(true)
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 17500
|
||||||
|
controller.Axes.LX.SetState(67)
|
||||||
|
|
||||||
|
CheckForOilChange := Mod(A_Index, 30)
|
||||||
|
CheckForMaintenance := Mod(A_Index, 180)
|
||||||
|
OCremain := 30 - CheckForOilChange
|
||||||
|
SetFormat, IntegerFast, d
|
||||||
|
EOremain := 180 - CheckForMaintenance
|
||||||
|
SetFormat, IntegerFast, d
|
||||||
|
ToolTip, Oil: %OCremain% race(s) remaining`nEngine: %EOremain% race(s) remaining, 250, 45, Screen
|
||||||
|
|
||||||
|
race_complete := false
|
||||||
|
SetTimer, RaceComplete, 225000
|
||||||
|
|
||||||
|
; Retry race if time is taking more than 5.5 mins
|
||||||
|
; (assume something went wrong with race)
|
||||||
|
SetTimer, RetryRace, 330000
|
||||||
|
|
||||||
|
loop {
|
||||||
|
;ToolTip, Racing, 100, 100, Screen
|
||||||
|
break_point := false
|
||||||
|
c1 := BitGrab(pix1x, pix1y, box_size)
|
||||||
|
for i, c in c1
|
||||||
|
{
|
||||||
|
d1 := Distance(c, color_check1)
|
||||||
|
if (d1 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
if (race_complete) {
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 50
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
ToolTip, Found color 1, 100, 100, Screen
|
||||||
|
SetTimer, RetryRace, off
|
||||||
|
gosub, ResetControllerState
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
RaceComplete:
|
||||||
|
race_complete := true
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Menu_End_Race:
|
||||||
|
ToolTip, Menuing, 100, 100, Screen
|
||||||
|
loop {
|
||||||
|
break_point := false
|
||||||
|
c2 := BitGrab(pix2x, pix2y, box_size)
|
||||||
|
for i, c in c2
|
||||||
|
{
|
||||||
|
d2 := Distance(c, color_check2)
|
||||||
|
if (d2 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
gosub, PressX
|
||||||
|
sleep, %color_2_delay%
|
||||||
|
}
|
||||||
|
ToolTip, Found color 2, 100, 100, Screen
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Tooltip
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
;Conduct Maintenance here.
|
||||||
|
if (CheckForMaintenance = 0) {
|
||||||
|
gosub, DoMaintenance
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (CheckForOilChange = 0) {
|
||||||
|
gosub, DoOilChange
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
RetryRace:
|
||||||
|
ToolTip, Retry Race, 100, 100, Screen
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
Gosub, ResetControllerState
|
||||||
|
Sleep 200
|
||||||
|
controller.Buttons.Options.SetState(true)
|
||||||
|
Sleep 200
|
||||||
|
controller.Buttons.Options.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
Goto, AFKLoop
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
|
||||||
|
PixelTuning:
|
||||||
|
x_ratio := ps_win_width/640
|
||||||
|
y_ratio := ps_win_height/360
|
||||||
|
pix1x := Floor(pix1x*x_ratio)
|
||||||
|
pix1y := Floor(pix1y*y_ratio)
|
||||||
|
pix2x := Floor(pix2x*x_ratio)
|
||||||
|
pix2y := Floor(pix2y*y_ratio)
|
||||||
|
tyreX := Floor(tyreX*x_ratio)
|
||||||
|
tyreY := Floor(tyreY*y_ratio)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
|
||||||
|
{
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
|
||||||
|
w := NumGet(rect, 8, "int")
|
||||||
|
h := NumGet(rect, 12, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertARGB(ARGB, Convert := 0)
|
||||||
|
{
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
RGB += ARGB
|
||||||
|
RGB := RGB & 0x00FFFFFF
|
||||||
|
if (Convert)
|
||||||
|
RGB := (RGB & 0xFF000000) | ((RGB & 0xFF0000) >> 16) | (RGB & 0x00FF00) | ((RGB & 0x0000FF) << 16)
|
||||||
|
|
||||||
|
return RGB
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
;MsgBox, This will test the number of Left/Right presses at the championship selection menu. `nTry this if you have not finished all cafe menus. `nPress OK to test
|
||||||
|
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
loop, %menu_loops% {
|
||||||
|
controller.Dpad.SetState(MenuDirect)
|
||||||
|
Sleep, 125
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*this section was used to test resoltuion specs
|
||||||
|
|
||||||
|
/*
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
MsgBox, Width %ps_win_width% Height %ps_win_height% pix1 %pix1x%
|
||||||
|
*/
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
BitGrab(x, y, b)
|
||||||
|
{
|
||||||
|
HWND := WinExist("PS Remote Play")
|
||||||
|
pToken := Gdip_Startup()
|
||||||
|
pBitmap := Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
|
||||||
|
pixs := []
|
||||||
|
for i in range(-1*b, b+1){
|
||||||
|
for j in range(-1*b, b+1){
|
||||||
|
pixel := Gdip_GetPixel(pBitmap,x+i,y+j)
|
||||||
|
rgb := ConvertARGB( pixel )
|
||||||
|
pixs.Push(rgb)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdip_DisposeImage(pBitmap)
|
||||||
|
Gdip_Shutdown(pToken)
|
||||||
|
return pixs
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
{
|
||||||
|
WinGetPos,,, Width, Height, ahk_id %hwnd%
|
||||||
|
hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
|
||||||
|
RegExMatch(A_OsVersion, "\d+", Version)
|
||||||
|
PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
|
||||||
|
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
|
||||||
|
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
|
||||||
|
return pBitmap
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check1 := PixelColorSimple(pix1x, pix1y)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check2 := PixelColorSimple(pix2x, pix2y)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1){
|
||||||
|
ps_load_time1 := 12000
|
||||||
|
ps_load_time2 := 6000
|
||||||
|
ps_load_time3 := 9000
|
||||||
|
}
|
||||||
|
if (SysCheck = 2){
|
||||||
|
ps_load_time1 := 37000
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 33000
|
||||||
|
}
|
||||||
|
if (SysCheck = 3){
|
||||||
|
ps_load_time1 := 37000
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 33000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
MenuSel:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (MenuCheck = 1){
|
||||||
|
menu_s := 1
|
||||||
|
}
|
||||||
|
if (MenuCheck = 2){
|
||||||
|
menu_s := 2
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Reset:
|
||||||
|
gosub, PauseLoop
|
||||||
|
Reload
|
||||||
|
Sleep 1000
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
range(start, stop:="", step:=1) {
|
||||||
|
static range := { _NewEnum: Func("_RangeNewEnum") }
|
||||||
|
if !step
|
||||||
|
throw "range(): Parameter 'step' must not be 0 or blank"
|
||||||
|
if (stop == "")
|
||||||
|
stop := start, start := 0
|
||||||
|
; Formula: r[i] := start + step*i ; r = range object, i = 0-based index
|
||||||
|
; For a postive 'step', the constraints are i >= 0 and r[i] < stop
|
||||||
|
; For a negative 'step', the constraints are i >= 0 and r[i] > stop
|
||||||
|
; No result is returned if r[0] does not meet the value constraint
|
||||||
|
if (step > 0 ? start < stop : start > stop) ;// start == start + step*0
|
||||||
|
return { base: range, start: start, stop: stop, step: step }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_RangeNewEnum(r) {
|
||||||
|
static enum := { "Next": Func("_RangeEnumNext") }
|
||||||
|
return { base: enum, r: r, i: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_RangeEnumNext(enum, ByRef k, ByRef v:="") {
|
||||||
|
stop := enum.r.stop, step := enum.r.step
|
||||||
|
, k := enum.r.start + step*enum.i
|
||||||
|
if (ret := step > 0 ? k < stop : k > stop)
|
||||||
|
enum.i += 1
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Sleep(ms=1)
|
||||||
|
{
|
||||||
|
global timeBeginPeriodHasAlreadyBeenCalled
|
||||||
|
if (timeBeginPeriodHasAlreadyBeenCalled != 1)
|
||||||
|
{
|
||||||
|
DllCall("Winmm.dll\timeBeginPeriod", UInt, 1)
|
||||||
|
timeBeginPeriodHasAlreadyBeenCalled := 1
|
||||||
|
}
|
||||||
|
DllCall("Sleep", UInt, ms)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
@@ -0,0 +1,787 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
#Include Lib\Gdip.ahk
|
||||||
|
#Include Lib\AHK-ViGEm-Bus.ahk
|
||||||
|
|
||||||
|
hModule := DllCall("LoadLibrary", "Str", A_LineFile "\..\Lib\SuperSleep.dll", "Ptr")
|
||||||
|
SuperSleep := DllCall("GetProcAddress", "Ptr", DllCall("GetModuleHandle", "Str", A_LineFile "\..\Lib\SuperSleep.dll", "Ptr"), "AStr", "super_sleep", "Ptr")
|
||||||
|
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
Global t := 220000
|
||||||
|
intensity := 230
|
||||||
|
delay := 300
|
||||||
|
init_delay := 10000
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
box_size := 3
|
||||||
|
color_check1 := 0xBBE044
|
||||||
|
color_check2 := 0xBBE044
|
||||||
|
color_2_delay := 500
|
||||||
|
|
||||||
|
color_tyre_overheat := 0xD42304
|
||||||
|
tyres_overheating := false
|
||||||
|
tyreX := 166
|
||||||
|
tyreY := 364
|
||||||
|
|
||||||
|
; resolution parameters and pixel search locations
|
||||||
|
ps_win_width := 640
|
||||||
|
ps_win_height := 360
|
||||||
|
pix1x := 458
|
||||||
|
pix1y := 114
|
||||||
|
pix2x := 607
|
||||||
|
pix2y := 319
|
||||||
|
tolerance := 20
|
||||||
|
bm_delay := 100
|
||||||
|
box_size := 2
|
||||||
|
|
||||||
|
ps_load_time1 := 12000
|
||||||
|
ps_load_time2 := 6000
|
||||||
|
ps_load_time3 := 9000
|
||||||
|
|
||||||
|
; Create a new controller controller
|
||||||
|
Global controller := new ViGEmDS4()
|
||||||
|
controller.SubscribeFeedback(Func("OnFeedback"))
|
||||||
|
|
||||||
|
OnFeedback(largeMotor, smallMotor, lightbarColor){
|
||||||
|
;OutputDebug % "AHK| Feedback received - LargeMotor: " largeMotor ", SmallMotor: " smallMotor ", LightBarColor: " lightbarColor
|
||||||
|
}
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
Gui, Add, Button, x15 y70 w70 default gGetColo_p, Stuck Leaderboard
|
||||||
|
Gui, Add, Button, x110 y70 w70 default gGetColo_g, Stuck Replay
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
Gui, Add, Radio, Group x15 y115 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
Gui, Add, Radio, x70 y115 altsubmit gPSystem, PS4
|
||||||
|
Gui, Add, Radio, x125 y115 altsubmit gPSystem, PS4 Pro
|
||||||
|
;Gui, Add, Radio, Group x15 y130 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
;Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
Gui, Add, Button, x70 y135 w70 default gReset, Reset
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
Gui, 2: Add, Text, x100 y90, Color 2 Delay
|
||||||
|
Gui, 2: Add, Edit, x100 y110 w40 vD, %color_2_delay%
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h170, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
GuiControlGet, color_2_delay, 2:, D
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t := 220000
|
||||||
|
intensity := 230
|
||||||
|
delay := 300
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
GuiControl, 2:, D, %color_2_delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
id := ""
|
||||||
|
SetKeyDelay, 10
|
||||||
|
Process, priority, , High
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
if (id = "")
|
||||||
|
return
|
||||||
|
gosub, PauseLoop
|
||||||
|
CoordMode, Pixel, Screen
|
||||||
|
CoordMode, ToolTip, Screen
|
||||||
|
sleep 1000
|
||||||
|
gosub, AFKLoop
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
gosub, ResetControllerState
|
||||||
|
gosub, PressX
|
||||||
|
gosub, Race
|
||||||
|
gosub, Menu_End_Race
|
||||||
|
gosub, Menu_Start_Race
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
controller.Buttons.Cross.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
PressO:
|
||||||
|
; Just for menuing, does not hold O down
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
; For turning
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 50
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
Sleep(100)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
Sleep(100)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
; Set the time you want to turn for in miliseconds and how hard (50, 100), 100 being the most, 50 being neutral
|
||||||
|
Turn_Right(sleept, inten){
|
||||||
|
t := sleept
|
||||||
|
controller.Axes.LX.SetState(inten)
|
||||||
|
gosub, TurnRight
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
}
|
||||||
|
|
||||||
|
; Set the time you want to turn for in miliseconds and how hard (0, 50), 0 being the most
|
||||||
|
Turn_Left(sleept, inten){
|
||||||
|
t := sleept
|
||||||
|
controller.Axes.LX.SetState(inten)
|
||||||
|
gosub, TurnLeft
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
ResetControllerState:
|
||||||
|
controller.Axes.RT.SetState(0)
|
||||||
|
controller.Buttons.R2.SetState(false)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Axes.LX.SetState(50)
|
||||||
|
controller.Axes.LY.SetState(50)
|
||||||
|
controller.Axes.RX.SetState(50)
|
||||||
|
controller.Axes.RY.SetState(50)
|
||||||
|
controller.Button.LS.SetState(false)
|
||||||
|
controller.Button.RS.SetState(false)
|
||||||
|
controller.Button.RT.SetState(false)
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
controller.Buttons.Square.SetState(false)
|
||||||
|
controller.Buttons.Triangle.SetState(false)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
;This will do only an oil change. will leave user at race menu to resume.
|
||||||
|
DoOilChange:
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 2800
|
||||||
|
loop, 2 {
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
Sleep, 2000
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
Sleep, 3000
|
||||||
|
controller.Dpad.SetState("Up")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 4800
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
;This will do complete maintenance on the car including oil, engine and body. will leave user at race menu to resume.
|
||||||
|
DoMaintenance:
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 2800
|
||||||
|
loop, 2 {
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
Sleep, 2000
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 7000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, 8500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
Sleep, 3000
|
||||||
|
controller.Dpad.SetState("Up")
|
||||||
|
Sleep, 140
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
controller.Dpad.SetState("Left")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 4800
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Menu_Start_Race:
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 100
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 250
|
||||||
|
loop, %menu_loops% {
|
||||||
|
controller.Dpad.SetState(MenuDirect)
|
||||||
|
Sleep, 100
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 250
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
gosub, PressX
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
Tooltip
|
||||||
|
controller.Buttons.Cross.SetState(true)
|
||||||
|
controller.Dpad.SetState("Down")
|
||||||
|
Sleep, 17500
|
||||||
|
controller.Axes.LX.SetState(67)
|
||||||
|
|
||||||
|
CheckForOilChange := Mod(A_Index, 30)
|
||||||
|
CheckForMaintenance := Mod(A_Index, 180)
|
||||||
|
OCremain := 30 - CheckForOilChange
|
||||||
|
SetFormat, IntegerFast, d
|
||||||
|
EOremain := 180 - CheckForMaintenance
|
||||||
|
SetFormat, IntegerFast, d
|
||||||
|
ToolTip, Oil: %OCremain% race(s) remaining`nEngine: %EOremain% race(s) remaining, 250, 45, Screen
|
||||||
|
|
||||||
|
race_complete := false
|
||||||
|
SetTimer, RaceComplete, 225000
|
||||||
|
|
||||||
|
; Retry race if time is taking more than 5.5 mins
|
||||||
|
; (assume something went wrong with race)
|
||||||
|
SetTimer, RetryRace, 330000
|
||||||
|
|
||||||
|
loop {
|
||||||
|
;ToolTip, Racing, 100, 100, Screen
|
||||||
|
break_point := false
|
||||||
|
c1 := BitGrab(pix1x, pix1y, box_size)
|
||||||
|
for i, c in c1
|
||||||
|
{
|
||||||
|
d1 := Distance(c, color_check1)
|
||||||
|
if (d1 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
if (race_complete) {
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 50
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
ToolTip, Found color 1, 100, 100, Screen
|
||||||
|
SetTimer, RetryRace, off
|
||||||
|
gosub, ResetControllerState
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
RaceComplete:
|
||||||
|
race_complete := true
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Menu_End_Race:
|
||||||
|
ToolTip, Menuing, 100, 100, Screen
|
||||||
|
loop {
|
||||||
|
break_point := false
|
||||||
|
c2 := BitGrab(pix2x, pix2y, box_size)
|
||||||
|
for i, c in c2
|
||||||
|
{
|
||||||
|
d2 := Distance(c, color_check2)
|
||||||
|
if (d2 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
gosub, PressX
|
||||||
|
sleep, %color_2_delay%
|
||||||
|
}
|
||||||
|
ToolTip, Found color 2, 100, 100, Screen
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Tooltip
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
controller.Buttons.Circle.SetState(true)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Buttons.Circle.SetState(false)
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
;Conduct Maintenance here.
|
||||||
|
if (CheckForMaintenance = 0) {
|
||||||
|
gosub, DoMaintenance
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (CheckForOilChange = 0) {
|
||||||
|
gosub, DoOilChange
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
RetryRace:
|
||||||
|
ToolTip, Retry Race, 100, 100, Screen
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
Gosub, ResetControllerState
|
||||||
|
Sleep 200
|
||||||
|
controller.Buttons.Options.SetState(true)
|
||||||
|
Sleep 200
|
||||||
|
controller.Buttons.Options.SetState(false)
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("Right")
|
||||||
|
Sleep, 200
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
Goto, AFKLoop
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
|
||||||
|
PixelTuning:
|
||||||
|
x_ratio := ps_win_width/640
|
||||||
|
y_ratio := ps_win_height/360
|
||||||
|
pix1x := Floor(pix1x*x_ratio)
|
||||||
|
pix1y := Floor(pix1y*y_ratio)
|
||||||
|
pix2x := Floor(pix2x*x_ratio)
|
||||||
|
pix2y := Floor(pix2y*y_ratio)
|
||||||
|
tyreX := Floor(tyreX*x_ratio)
|
||||||
|
tyreY := Floor(tyreY*y_ratio)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
|
||||||
|
{
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
|
||||||
|
w := NumGet(rect, 8, "int")
|
||||||
|
h := NumGet(rect, 12, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertARGB(ARGB, Convert := 0)
|
||||||
|
{
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
RGB += ARGB
|
||||||
|
RGB := RGB & 0x00FFFFFF
|
||||||
|
if (Convert)
|
||||||
|
RGB := (RGB & 0xFF000000) | ((RGB & 0xFF0000) >> 16) | (RGB & 0x00FF00) | ((RGB & 0x0000FF) << 16)
|
||||||
|
|
||||||
|
return RGB
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
;MsgBox, This will test the number of Left/Right presses at the championship selection menu. `nTry this if you have not finished all cafe menus. `nPress OK to test
|
||||||
|
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
loop, %menu_loops% {
|
||||||
|
controller.Dpad.SetState(MenuDirect)
|
||||||
|
Sleep, 125
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*this section was used to test resoltuion specs
|
||||||
|
|
||||||
|
/*
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
MsgBox, Width %ps_win_width% Height %ps_win_height% pix1 %pix1x%
|
||||||
|
*/
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
BitGrab(x, y, b)
|
||||||
|
{
|
||||||
|
HWND := WinExist("PS Remote Play")
|
||||||
|
pToken := Gdip_Startup()
|
||||||
|
pBitmap := Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
|
||||||
|
pixs := []
|
||||||
|
for i in range(-1*b, b+1){
|
||||||
|
for j in range(-1*b, b+1){
|
||||||
|
pixel := Gdip_GetPixel(pBitmap,x+i,y+j)
|
||||||
|
rgb := ConvertARGB( pixel )
|
||||||
|
pixs.Push(rgb)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdip_DisposeImage(pBitmap)
|
||||||
|
Gdip_Shutdown(pToken)
|
||||||
|
return pixs
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
{
|
||||||
|
WinGetPos,,, Width, Height, ahk_id %hwnd%
|
||||||
|
hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
|
||||||
|
RegExMatch(A_OsVersion, "\d+", Version)
|
||||||
|
PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
|
||||||
|
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
|
||||||
|
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
|
||||||
|
return pBitmap
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check1 := PixelColorSimple(pix1x, pix1y)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check2 := PixelColorSimple(pix2x, pix2y)
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1){
|
||||||
|
ps_load_time1 := 12000
|
||||||
|
ps_load_time2 := 6000
|
||||||
|
ps_load_time3 := 9000
|
||||||
|
}
|
||||||
|
if (SysCheck = 2){
|
||||||
|
ps_load_time1 := 37000
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 33000
|
||||||
|
}
|
||||||
|
if (SysCheck = 3){
|
||||||
|
ps_load_time1 := 37000
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 33000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
MenuSel:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (MenuCheck = 1){
|
||||||
|
menu_s := 1
|
||||||
|
}
|
||||||
|
if (MenuCheck = 2){
|
||||||
|
menu_s := 2
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Reset:
|
||||||
|
gosub, PauseLoop
|
||||||
|
Reload
|
||||||
|
Sleep 1000
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
controller.Buttons.Cross.SetState(false)
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
controller.Dpad.SetState("None")
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
range(start, stop:="", step:=1) {
|
||||||
|
static range := { _NewEnum: Func("_RangeNewEnum") }
|
||||||
|
if !step
|
||||||
|
throw "range(): Parameter 'step' must not be 0 or blank"
|
||||||
|
if (stop == "")
|
||||||
|
stop := start, start := 0
|
||||||
|
; Formula: r[i] := start + step*i ; r = range object, i = 0-based index
|
||||||
|
; For a postive 'step', the constraints are i >= 0 and r[i] < stop
|
||||||
|
; For a negative 'step', the constraints are i >= 0 and r[i] > stop
|
||||||
|
; No result is returned if r[0] does not meet the value constraint
|
||||||
|
if (step > 0 ? start < stop : start > stop) ;// start == start + step*0
|
||||||
|
return { base: range, start: start, stop: stop, step: step }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_RangeNewEnum(r) {
|
||||||
|
static enum := { "Next": Func("_RangeEnumNext") }
|
||||||
|
return { base: enum, r: r, i: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
_RangeEnumNext(enum, ByRef k, ByRef v:="") {
|
||||||
|
stop := enum.r.stop, step := enum.r.step
|
||||||
|
, k := enum.r.start + step*enum.i
|
||||||
|
if (ret := step > 0 ? k < stop : k > stop)
|
||||||
|
enum.i += 1
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Sleep(ms=1)
|
||||||
|
{
|
||||||
|
global timeBeginPeriodHasAlreadyBeenCalled
|
||||||
|
if (timeBeginPeriodHasAlreadyBeenCalled != 1)
|
||||||
|
{
|
||||||
|
DllCall("Winmm.dll\timeBeginPeriod", UInt, 1)
|
||||||
|
timeBeginPeriodHasAlreadyBeenCalled := 1
|
||||||
|
}
|
||||||
|
DllCall("Sleep", UInt, ms)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
@@ -0,0 +1,683 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
#Include Lib\Gdip.ahk
|
||||||
|
;#include Lib\AHK-ViGEm-Bus.ahk
|
||||||
|
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
; RUF pink 0x583375
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
t := 220000
|
||||||
|
intensity := 230
|
||||||
|
delay := 160
|
||||||
|
init_delay := 10000
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
box_size := 3
|
||||||
|
color_check1 := 0xBBE044
|
||||||
|
color_check2 := 0xBBE044
|
||||||
|
color_2_delay := 1500
|
||||||
|
|
||||||
|
color_tyre_overheat := 0xD42304
|
||||||
|
tyres_overheating := false
|
||||||
|
|
||||||
|
; resolution parameters and pixel search locations
|
||||||
|
ps_win_width := 720
|
||||||
|
tolerance := 20
|
||||||
|
bm_delay := 100
|
||||||
|
box_size := 2
|
||||||
|
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
|
||||||
|
/*
|
||||||
|
; Create a new controller controller
|
||||||
|
controller := new ViGEmDS4()
|
||||||
|
controller.SubscribeFeedback(Func("OnFeedback"))
|
||||||
|
|
||||||
|
OnFeedback(largeMotor, smallMotor, lightbarColor){
|
||||||
|
;OutputDebug % "AHK| Feedback received - LargeMotor: " largeMotor ", SmallMotor: " smallMotor ", LightBarColor: " lightbarColor
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
Gui, Add, Button, x15 y70 w70 default gGetColo_p, Stuck Leaderboard
|
||||||
|
Gui, Add, Button, x110 y70 w70 default gGetColo_g, Stuck Replay
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
Gui, Add, Radio, Group x15 y115 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
Gui, Add, Radio, x70 y115 altsubmit gPSystem, PS4
|
||||||
|
;Gui, Add, Radio, Group x15 y130 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
;Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
Gui, Add, Button, x70 y135 w70 default gReset, Reset
|
||||||
|
Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
Gui, 2: Add, Text, x100 y90, Color 2 Delay
|
||||||
|
Gui, 2: Add, Edit, x100 y110 w40 vD, %color_2_delay%
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h170, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
GuiControlGet, color_2_delay, 2:, D
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t = 220000
|
||||||
|
intensity = 220
|
||||||
|
delay := 140
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
GuiControl, 2:, D, %color_2_delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
id := ""
|
||||||
|
SetKeyDelay, 10
|
||||||
|
Process, priority, , High
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
if (id = "")
|
||||||
|
return
|
||||||
|
gosub, PauseLoop
|
||||||
|
CoordMode, Pixel, Screen
|
||||||
|
CoordMode, ToolTip, Screen
|
||||||
|
sleep 1000
|
||||||
|
gosub, AFKLoop
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop {
|
||||||
|
;gosub, Menu
|
||||||
|
gosub, PressX
|
||||||
|
DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version
|
||||||
|
gosub, Race
|
||||||
|
/*
|
||||||
|
if (tyres_overheating) {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
gosub, Menu
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PressO:
|
||||||
|
; Just for menuing, does not hold O down
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 200)
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
; For turning
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until tyres_overheating || A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until tyres_overheating || A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
CheckTyresOverheating:
|
||||||
|
tc := BitGrab(tyreX, tyreY, box_size)
|
||||||
|
for i, c in tc
|
||||||
|
{
|
||||||
|
td := Distance(c, color_tyre_overheat)
|
||||||
|
if (td < tolerance ) {
|
||||||
|
tyres_overheating := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
RetryRace:
|
||||||
|
Gosub, PauseLoop
|
||||||
|
Sleep 500
|
||||||
|
tyres_overheating := false
|
||||||
|
controller.Buttons.Options.SetState(true)
|
||||||
|
Sleep 500
|
||||||
|
controller.Buttons.Options.SetState(false)
|
||||||
|
Sleep, 500
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Goto, AFKLoop
|
||||||
|
return
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 8200)
|
||||||
|
;SetTimer, CheckTyresOverheating, 1000
|
||||||
|
gosub TurnRight
|
||||||
|
/*
|
||||||
|
; 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
|
||||||
|
Screen: 218, 359 (less often used)
|
||||||
|
Window: 222, 357 (default)
|
||||||
|
Client: 214, 326 (recommended)
|
||||||
|
Color: 3F1757 (Red=3F Green=17 Blue=57)
|
||||||
|
|
||||||
|
Screen: 247, 65 (less often used)
|
||||||
|
Window: -129, -376 (default)
|
||||||
|
Client: -129, -376 (recommended)
|
||||||
|
Color: FD3C37 (Red=FD Green=3C Blue=37)
|
||||||
|
|
||||||
|
Screen: 210, 64 (less often used)
|
||||||
|
Window: 210, 64 (default)
|
||||||
|
Client: 202, 33 (recommended)
|
||||||
|
Color: 5091E9 (Red=50 Green=91 Blue=E9)
|
||||||
|
|
||||||
|
Screen: 261, 39 (less often used)
|
||||||
|
Window: 261, 39 (default)
|
||||||
|
Client: 253, 8 (recommended)
|
||||||
|
Color: A774A9 (Red=A7 Green=74 Blue=A9)
|
||||||
|
|
||||||
|
Screen: 263, 74 (less often used)
|
||||||
|
Window: 263, 74 (default)
|
||||||
|
Client: 255, 43 (recommended)
|
||||||
|
Color: FF3632 (Red=FF Green=36 Blue=32)
|
||||||
|
*/
|
||||||
|
loop {
|
||||||
|
/*
|
||||||
|
if (tyres_overheating) {
|
||||||
|
Goto, RetryRace
|
||||||
|
return
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
break_point := false
|
||||||
|
c1 := BitGrab(pix1x, pix1y, box_size)
|
||||||
|
for i, c in c1
|
||||||
|
{
|
||||||
|
d1 := Distance(c, color_check1)
|
||||||
|
if (d1 < tolerance ) {
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 140
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
/*
|
||||||
|
PixelSearch, x, y, pix1x-10, pix1y-10, pix1x+10, pix1y+10, %color_check1%, 32, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 140
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
;ToolTip, Found color 1, 100, 100, Screen
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu:
|
||||||
|
if (menu_s = 1) {
|
||||||
|
gosub, Menu_pixel
|
||||||
|
}
|
||||||
|
if (menu_s = 2) {
|
||||||
|
gosub, Menu_time
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_pixel:
|
||||||
|
;ToolTip, Menuing, 100, 100, Screen
|
||||||
|
loop {
|
||||||
|
break_point := false
|
||||||
|
c2 := BitGrab(pix2x, pix2y, box_size)
|
||||||
|
for i, c in c2
|
||||||
|
{
|
||||||
|
d2 := Distance(c, color_check2)
|
||||||
|
if (d2 < tolerance ){
|
||||||
|
break_point := true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (break_point)
|
||||||
|
break
|
||||||
|
gosub, PressX
|
||||||
|
sleep %color_2_delay%
|
||||||
|
sleep, %bm_delay%
|
||||||
|
}
|
||||||
|
;ToolTip, Found color 2, 100, 100, Screen
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1200
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_time:
|
||||||
|
loop, 9 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1700
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 100
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 400
|
||||||
|
}
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
return
|
||||||
|
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 0, 0
|
||||||
|
gosub, Init
|
||||||
|
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
RPwind:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, -700, -400, 0, 0
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
|
||||||
|
{
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
|
||||||
|
w := NumGet(rect, 8, "int")
|
||||||
|
h := NumGet(rect, 12, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
ConvertARGB(ARGB, Convert := 0)
|
||||||
|
{
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
RGB += ARGB
|
||||||
|
RGB := RGB & 0x00FFFFFF
|
||||||
|
if (Convert)
|
||||||
|
RGB := (RGB & 0xFF000000) | ((RGB & 0xFF0000) >> 16) | (RGB & 0x00FF00) | ((RGB & 0x0000FF) << 16)
|
||||||
|
|
||||||
|
return RGB
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
MsgBox, This will test the number of Left/Right presses at the championship selection menu. `nTry this if you have not finished all cafe menus. `nPress OK to test
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
/*this section was used to test resoltuion specs
|
||||||
|
|
||||||
|
/*
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
MsgBox, Width %ps_win_width% Height %ps_win_height% pix1 %pix1x%
|
||||||
|
*/
|
||||||
|
return
|
||||||
|
|
||||||
|
BitGrab(x, y, b)
|
||||||
|
{
|
||||||
|
HWND := WinExist("PS Remote Play")
|
||||||
|
pToken := Gdip_Startup()
|
||||||
|
pBitmap := Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
|
||||||
|
pixs := []
|
||||||
|
for i in range(-1*b, b+1) {
|
||||||
|
for j in range(-1*b, b+1) {
|
||||||
|
pixel := Gdip_GetPixel(pBitmap,x+i,y+j)
|
||||||
|
rgb := ConvertARGB( pixel )
|
||||||
|
pixs.Push(rgb)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdip_DisposeImage(pBitmap)
|
||||||
|
Gdip_Shutdown(pToken)
|
||||||
|
return pixs
|
||||||
|
}
|
||||||
|
|
||||||
|
Gdip_BitmapFromHWND2(hwnd)
|
||||||
|
{
|
||||||
|
WinGetPos,,, Width, Height, ahk_id %hwnd%
|
||||||
|
hbm := CreateDIBSection(Width, Height), hdc := CreateCompatibleDC(), obm := SelectObject(hdc, hbm)
|
||||||
|
RegExMatch(A_OsVersion, "\d+", Version)
|
||||||
|
PrintWindow(hwnd, hdc, Version >= 8 ? 2 : 0)
|
||||||
|
pBitmap := Gdip_CreateBitmapFromHBITMAP(hbm)
|
||||||
|
SelectObject(hdc, obm), DeleteObject(hbm), DeleteDC(hdc)
|
||||||
|
return pBitmap
|
||||||
|
}
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check1 := PixelColorSimple(pix1x, pix1y)
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
color_check2 := PixelColorSimple(pix2x, pix2y)
|
||||||
|
return
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1) {
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
}
|
||||||
|
if (SysCheck = 2) {
|
||||||
|
ps_load_time1 := 41500
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 40000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
MenuSel:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (MenuCheck = 1) {
|
||||||
|
menu_s := 1
|
||||||
|
}
|
||||||
|
if (MenuCheck = 2) {
|
||||||
|
menu_s := 2s
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Init:
|
||||||
|
ps_win_height := Floor((ps_win_width * 9 / 16) + 2 * 80) ; PS menu bar is approx 80px
|
||||||
|
ps_win_height2 := Floor(ps_win_width * 9 / 16) ; PS display is in 16/9 ("without" the black bars)
|
||||||
|
black_bar_height := Floor((ps_win_height - ps_win_height2) / 2)
|
||||||
|
;msgbox, %ps_win_height% %ps_win_height2% %black_bar_height%
|
||||||
|
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetWindowRect", "ptr", id, "ptr", &rect)
|
||||||
|
wwr := NumGet(rect, 8, "int")
|
||||||
|
hwr := NumGet(rect, 12, "int")
|
||||||
|
|
||||||
|
DllCall("GetClientRect", "ptr", id, "ptr", &rect)
|
||||||
|
wcr := NumGet(rect, 8, "int")
|
||||||
|
hcr := NumGet(rect, 12, "int")
|
||||||
|
|
||||||
|
border := wwr - wcr ;xborder = yborder
|
||||||
|
cap := hwr - hcr - border ;cap = caption = title bar height
|
||||||
|
;msgbox, %wwr% %hwr% %wcr% %hcr% %border% %cap%
|
||||||
|
|
||||||
|
ps_win_width := ps_win_width + border
|
||||||
|
ps_win_height := ps_win_height + border + cap
|
||||||
|
ps_win_height2 := ps_win_height2 + border + cap
|
||||||
|
;msgbox, %ps_win_width% %ps_win_height%
|
||||||
|
|
||||||
|
pix1x := Floor(ps_win_width * 0.6982)
|
||||||
|
pix1y := Floor((ps_win_height2 * 0.2857) + black_bar_height)
|
||||||
|
pix2x := Floor(ps_win_width * 0.9253)
|
||||||
|
pix2y := Floor((ps_win_height2 * 0.7995) + black_bar_height)
|
||||||
|
tyreX := Floor(ps_win_width * 0.2530)
|
||||||
|
tyreY := Floor((ps_win_height2 * 0.9123) + black_bar_height)
|
||||||
|
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, ps_win_width, ps_win_height
|
||||||
|
return
|
||||||
|
|
||||||
|
Reset:
|
||||||
|
gosub, PauseLoop
|
||||||
|
Reload
|
||||||
|
Sleep 1000
|
||||||
|
return
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
range(start, stop:="", step:=1) {
|
||||||
|
static range := { _NewEnum: Func("_RangeNewEnum") }
|
||||||
|
if !step
|
||||||
|
throw "range(): Parameter 'step' must not be 0 or blank"
|
||||||
|
if (stop == "")
|
||||||
|
stop := start, start := 0
|
||||||
|
; Formula: r[i] := start + step*i ; r = range object, i = 0-based index
|
||||||
|
; For a postive 'step', the constraints are i >= 0 and r[i] < stop
|
||||||
|
; For a negative 'step', the constraints are i >= 0 and r[i] > stop
|
||||||
|
; No result is returned if r[0] does not meet the value constraint
|
||||||
|
if (step > 0 ? start < stop : start > stop) ;// start == start + step*0
|
||||||
|
return { base: range, start: start, stop: stop, step: step }
|
||||||
|
}
|
||||||
|
|
||||||
|
_RangeNewEnum(r) {
|
||||||
|
static enum := { "Next": Func("_RangeEnumNext") }
|
||||||
|
return { base: enum, r: r, i: 0 }
|
||||||
|
}
|
||||||
|
|
||||||
|
_RangeEnumNext(enum, ByRef k, ByRef v:="") {
|
||||||
|
stop := enum.r.stop, step := enum.r.step
|
||||||
|
, k := enum.r.start + step*enum.i
|
||||||
|
if (ret := step > 0 ? k < stop : k > stop)
|
||||||
|
enum.i += 1
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
|
|
||||||
|
/*
|
||||||
|
Pink RUF color"
|
||||||
|
which is the standart first one to buy if you want to buy car manufactur color (for me german GT7 i think its same for everyone)
|
||||||
|
0xFA559F
|
||||||
|
|
||||||
|
i have put that into Color check 1 and 2 works since 5 cycles - so maybe put them in with like (not tested)
|
||||||
|
(i think the first option that gets shown to buy a new color is the easiest to explain for people to buy except for colors the car exists in anyways (venom green)
|
||||||
|
here is the Hex Code for Porsche "Sternrubin" Ruby or Starruby depending on language:
|
||||||
|
0xBA3A64
|
||||||
|
*/
|
||||||
@@ -0,0 +1,726 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
t := 220000
|
||||||
|
intensity := 220
|
||||||
|
delay := 160
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
color_check1 := 0xFD3C37
|
||||||
|
color_check2 := 0x4DCF75
|
||||||
|
c1_alt := false
|
||||||
|
color_2_delay := 1500
|
||||||
|
|
||||||
|
|
||||||
|
; resolution parameters and pixel search locations
|
||||||
|
ps_win_width := 640
|
||||||
|
ps_win_height := 360
|
||||||
|
pix1x := 247
|
||||||
|
pix1y := 65
|
||||||
|
pix2x := 342
|
||||||
|
pix2y := 362
|
||||||
|
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
;Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
;Gui, Add, Button, x15 y70 w70 default gGetColo_p, ColorP1
|
||||||
|
; Gui, Add, Button, x110 y70 w70 default gGetColo_g, ColorP2
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
; Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
; Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
; Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
; Gui, Add, Radio, Group x15 y100 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
; Gui, Add, Radio, x70 y100 altsubmit gPSystem, PS4
|
||||||
|
; Gui, Add, Radio, Group x15 y120 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
; Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
; Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
Gui, 2: Add, Text, x100 y90, Color 2 Delay
|
||||||
|
Gui, 2: Add, Edit, x100 y110 w40 vD, %color_2_delay%
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h150, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
GuiControlGet, color_2_delay, 2:, D
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t = 220000
|
||||||
|
intensity = 220
|
||||||
|
delay := 140
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
GuiControl, 2:, D, %color_2_delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
gosub, PixelTuning
|
||||||
|
|
||||||
|
SetKeyDelay, 10
|
||||||
|
|
||||||
|
;get to upper left hand menu
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to options menu
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to Controllers menu
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to wireless controller 1p
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change steering controlls
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change pedal controlls
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;apply settings
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;back to menu
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
;enter world circuits
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 5000
|
||||||
|
|
||||||
|
;enter panam
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change car - selecing twice if good car was already selected
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;enter race
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 12000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
;change gearbox to auto
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
;start race
|
||||||
|
gosub, PressLeft
|
||||||
|
; gosub, PressX
|
||||||
|
|
||||||
|
; ;pause race
|
||||||
|
; Sleep, 5000
|
||||||
|
; ; TODO below doesn't go to exit menu FIXME
|
||||||
|
; gosub, PressO
|
||||||
|
; gosub, PressRight
|
||||||
|
|
||||||
|
MsgBox, Settings set for AFK
|
||||||
|
|
||||||
|
return
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
;gosub, Menu
|
||||||
|
gosub, PressX
|
||||||
|
DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version
|
||||||
|
gosub, Race
|
||||||
|
gosub, Menu
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressO:
|
||||||
|
; Just for menuing, does not hold O down
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressLeft:
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressDown:
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressUp:
|
||||||
|
ControlSend,, {%brake% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%brake% up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 8200)
|
||||||
|
gosub TurnRight
|
||||||
|
/*
|
||||||
|
; 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
|
||||||
|
Screen: 218, 359 (less often used)
|
||||||
|
Window: 222, 357 (default)
|
||||||
|
Client: 214, 326 (recommended)
|
||||||
|
Color: 3F1757 (Red=3F Green=17 Blue=57)
|
||||||
|
|
||||||
|
Screen: 247, 65 (less often used)
|
||||||
|
Window: -129, -376 (default)
|
||||||
|
Client: -129, -376 (recommended)
|
||||||
|
Color: FD3C37 (Red=FD Green=3C Blue=37)
|
||||||
|
|
||||||
|
Screen: 210, 64 (less often used)
|
||||||
|
Window: 210, 64 (default)
|
||||||
|
Client: 202, 33 (recommended)
|
||||||
|
Color: 5091E9 (Red=50 Green=91 Blue=E9)
|
||||||
|
|
||||||
|
Screen: 261, 39 (less often used)
|
||||||
|
Window: 261, 39 (default)
|
||||||
|
Client: 253, 8 (recommended)
|
||||||
|
Color: A774A9 (Red=A7 Green=74 Blue=A9)
|
||||||
|
*/
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, pix1x-2, pix1y-2, pix1x+2, pix1y+2, %color_check1%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 140
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu:
|
||||||
|
if (menu_s = 1){
|
||||||
|
gosub, Menu_pixel
|
||||||
|
}
|
||||||
|
if (menu_s = 2){
|
||||||
|
gosub, Menu_time
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_pixel:
|
||||||
|
;ToolTip, Menuing, 100, 100, Screen
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, pix2x-2, pix2y-2, pix2x+2, pix2y+2, %color_check2%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
gosub, PressX
|
||||||
|
sleep %color_2_delay%
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;ToolTip, Found color 2, 100, 100, Screen
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1200
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_time:
|
||||||
|
loop, 9{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1700
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
PixelTuning:
|
||||||
|
x_ratio := ps_win_width/640
|
||||||
|
y_ratio := ps_win_height/360
|
||||||
|
pix1x := Floor(pix1x*x_ratio)
|
||||||
|
pix1y := Floor(pix1y*y_ratio)
|
||||||
|
pix2x := Floor(pix2x*x_ratio)
|
||||||
|
pix2y := Floor(pix2y*y_ratio)
|
||||||
|
return
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
return
|
||||||
|
|
||||||
|
RPwind:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, -700, -400, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
|
||||||
|
{
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
|
||||||
|
w := NumGet(rect, 8, "int")
|
||||||
|
h := NumGet(rect, 12, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
gosub, PixelTuning
|
||||||
|
|
||||||
|
SetKeyDelay, 10
|
||||||
|
|
||||||
|
;get to upper left hand menu
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to options menu
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to Controllers menu
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to wireless controller 1p
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change steering controlls
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change pedal controlls
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;apply settings
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;back to menu
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
;enter world circuits
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 5000
|
||||||
|
|
||||||
|
;enter panam
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;enter race
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 12000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
;change gearbox to manual
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
;leave race
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 8000
|
||||||
|
|
||||||
|
;go back to main menu
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
MsgBox, Reverted settings after AFK
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check1 := PixelColorSimple(pix1x, pix1y)
|
||||||
|
;MsgBox, At the screen with [Replay] [Next Race], Press ColorP2
|
||||||
|
c1_alt := true
|
||||||
|
MsgBox, Put this in for color_check1 %color_check1%
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check2 := PixelColorSimple(pix2x, pix2y)
|
||||||
|
c1_alt := false
|
||||||
|
MsgBox, Put this in for color_check2 %color_check2%
|
||||||
|
return
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1){
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
}
|
||||||
|
if (SysCheck = 2){
|
||||||
|
ps_load_time1 := 41500
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 40000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
MenuSel:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (MenuCheck = 1){
|
||||||
|
menu_s := 1
|
||||||
|
}
|
||||||
|
if (MenuCheck = 2){
|
||||||
|
menu_s := 2
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
|
|
||||||
@@ -0,0 +1,720 @@
|
|||||||
|
#NoEnv
|
||||||
|
#MaxHotkeysPerInterval 99000000
|
||||||
|
#HotkeyInterval 99000000
|
||||||
|
#KeyHistory 0
|
||||||
|
ListLines Off
|
||||||
|
Process, Priority, , A
|
||||||
|
SetBatchLines, -1
|
||||||
|
SetKeyDelay, -1, -1
|
||||||
|
SetMouseDelay, -1
|
||||||
|
SetDefaultMouseSpeed, 0
|
||||||
|
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
|
||||||
|
|
||||||
|
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
|
||||||
|
DetectHiddenWindows, On
|
||||||
|
#Persistent
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
; --------- Controls
|
||||||
|
accel := "Enter"
|
||||||
|
turnLeft := "Left"
|
||||||
|
turnRight := "Right"
|
||||||
|
brake := "Up"
|
||||||
|
nitros := "Down"
|
||||||
|
|
||||||
|
; --------- Constants
|
||||||
|
; Time at turn in seconds and Stablizing control
|
||||||
|
t := 220000
|
||||||
|
intensity := 220
|
||||||
|
delay := 160
|
||||||
|
|
||||||
|
MenuDirect := "Right"
|
||||||
|
Menu_loops := 6
|
||||||
|
menu_s := 1
|
||||||
|
color_check1 := 0xFD3C37
|
||||||
|
color_check2 := 0x4DCF75
|
||||||
|
c1_alt := false
|
||||||
|
color_2_delay := 1500
|
||||||
|
|
||||||
|
|
||||||
|
; resolution parameters and pixel search locations
|
||||||
|
ps_win_width := 640
|
||||||
|
ps_win_height := 360
|
||||||
|
pix1x := 247
|
||||||
|
pix1y := 65
|
||||||
|
pix2x := 342
|
||||||
|
pix2y := 362
|
||||||
|
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
|
||||||
|
; ---------- Gui Setup -------------
|
||||||
|
Gui, -MaximizeBox
|
||||||
|
Gui, 2: -MaximizeBox
|
||||||
|
Gui, 2: -MinimizeBox
|
||||||
|
Gui, Color, c282a36, c6272a4
|
||||||
|
Gui, Add, Button, x15 y10 w70 default, Start
|
||||||
|
;Gui, Add, Button, x15 y40 w70 default gVariableWindow, Variables
|
||||||
|
;Gui, Add, Button, x15 y70 w70 default gGetColo_p, ColorP1
|
||||||
|
; Gui, Add, Button, x110 y70 w70 default gGetColo_g, ColorP2
|
||||||
|
Gui, Add, Button, x110 y10 w70 default gMenuTest, MenuTest
|
||||||
|
; Gui, Add, DropDownList, w50 Choose1 vMenuDirect, Right|Left
|
||||||
|
; Gui, Add, Edit, vMenu_loops w20 x165 y39, 6
|
||||||
|
; Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
; Gui, Add, Radio, Group x15 y100 altsubmit Checked gPSystem vSysCheck, PS5
|
||||||
|
; Gui, Add, Radio, x70 y100 altsubmit gPSystem, PS4
|
||||||
|
; Gui, Add, Radio, Group x15 y120 altsubmit Checked gMenuSel vMenuCheck, Pixel
|
||||||
|
; Gui, Add, Radio, x70 y120 altsubmit gMenuSel, Timing
|
||||||
|
; Gui, Font, ce8dfe3 s9 w550 Bold
|
||||||
|
|
||||||
|
;--------- Gui 2 Setup --------------
|
||||||
|
Gui, 2: Color, c535770, c6272a4
|
||||||
|
Gui, 2: Font, c11f s9 Bold
|
||||||
|
Gui, 2: Add, Text,, Turn Length (time miliseconds)
|
||||||
|
Gui, 2: Add, Edit, w70 vA, %t%
|
||||||
|
Gui, 2: Add, Text,, Turn Intensity
|
||||||
|
Gui, 2: Add, Edit, w40 vB, %intensity%
|
||||||
|
Gui, 2: Add, Text,, Turn Delay
|
||||||
|
Gui, 2: Add, Edit, w40 vC, %delay%
|
||||||
|
Gui, 2: Add, Text, x100 y90, Color 2 Delay
|
||||||
|
Gui, 2: Add, Edit, x100 y110 w40 vD, %color_2_delay%
|
||||||
|
|
||||||
|
Gui, 2: Add, Button, x20 y170 gSaveVars, Save
|
||||||
|
Gui, 2: Add, Button, x100 y170 gVarDef, Defaults
|
||||||
|
Gui, Show,w220 h150, GT7 Pan American AFK
|
||||||
|
return
|
||||||
|
|
||||||
|
VariableWindow:
|
||||||
|
Gui, 2: Show, w220 h205, Variables
|
||||||
|
return
|
||||||
|
|
||||||
|
SaveVars:
|
||||||
|
Gui, 2:Submit
|
||||||
|
GuiControlGet, t, 2:, A
|
||||||
|
GuiControlGet, intensity, 2:, B
|
||||||
|
GuiControlGet, delay, 2:, C
|
||||||
|
GuiControlGet, color_2_delay, 2:, D
|
||||||
|
return
|
||||||
|
|
||||||
|
VarDef:
|
||||||
|
t = 220000
|
||||||
|
intensity = 220
|
||||||
|
delay := 140
|
||||||
|
GuiControl, 2:, A, %t%
|
||||||
|
GuiControl, 2:, B, %intensity%
|
||||||
|
GuiControl, 2:, C, %delay%
|
||||||
|
GuiControl, 2:, D, %color_2_delay%
|
||||||
|
return
|
||||||
|
|
||||||
|
ButtonStart:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
gosub, PixelTuning
|
||||||
|
|
||||||
|
SetKeyDelay, 10
|
||||||
|
|
||||||
|
;get to upper left hand menu
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to options menu
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to Controllers menu
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to wireless controller 1p
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change steering controlls
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change pedal controlls
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change Nitros to down arrow
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;apply settings
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;back to menu
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
;enter world circuits
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 5000
|
||||||
|
|
||||||
|
;enter panam
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change car - selecing twice if good car was already selected
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;enter race
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 12000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
;change gearbox to auto
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
;start race
|
||||||
|
gosub, PressLeft
|
||||||
|
; gosub, PressX
|
||||||
|
|
||||||
|
; ;pause race
|
||||||
|
; Sleep, 5000
|
||||||
|
; ; TODO below doesn't go to exit menu FIXME
|
||||||
|
; gosub, PressO
|
||||||
|
; gosub, PressRight
|
||||||
|
|
||||||
|
MsgBox, Settings set for AFK
|
||||||
|
|
||||||
|
return
|
||||||
|
; ---------- Gui Setup End-------------
|
||||||
|
|
||||||
|
|
||||||
|
AFKLoop:
|
||||||
|
loop{
|
||||||
|
;gosub, Menu
|
||||||
|
gosub, PressX
|
||||||
|
DllCall("Sleep", "UInt", 10000) ; This is dependent on load time, probably different for ps4 version
|
||||||
|
gosub, Race
|
||||||
|
gosub, Menu
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
PressX:
|
||||||
|
; Just for menuing, does not hold X down
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressO:
|
||||||
|
; Just for menuing, does not hold O down
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressRight:
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressLeft:
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressDown:
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
PressUp:
|
||||||
|
ControlSend,, {%brake% down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {%brake% up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
return
|
||||||
|
|
||||||
|
; given time t in miliseconds, turn right for that long, with intensity being how much the turn button is held for
|
||||||
|
TurnRight:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
TurnLeft:
|
||||||
|
t0 := A_TickCount
|
||||||
|
tf := t0+t
|
||||||
|
|
||||||
|
loop {
|
||||||
|
ControlSend,, {%turnLeft% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", intensity)
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
|
||||||
|
DllCall("Sleep", "UInt", delay)
|
||||||
|
} until A_TickCount > tf
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
Race:
|
||||||
|
; Hold Acceleration and manage turning
|
||||||
|
|
||||||
|
ControlSend,, {%accel% down}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% down}, ahk_id %id%
|
||||||
|
DllCall("Sleep", "UInt", 8200)
|
||||||
|
gosub TurnRight
|
||||||
|
/*
|
||||||
|
; 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
|
||||||
|
Screen: 218, 359 (less often used)
|
||||||
|
Window: 222, 357 (default)
|
||||||
|
Client: 214, 326 (recommended)
|
||||||
|
Color: 3F1757 (Red=3F Green=17 Blue=57)
|
||||||
|
|
||||||
|
Screen: 247, 65 (less often used)
|
||||||
|
Window: -129, -376 (default)
|
||||||
|
Client: -129, -376 (recommended)
|
||||||
|
Color: FD3C37 (Red=FD Green=3C Blue=37)
|
||||||
|
|
||||||
|
Screen: 210, 64 (less often used)
|
||||||
|
Window: 210, 64 (default)
|
||||||
|
Client: 202, 33 (recommended)
|
||||||
|
Color: 5091E9 (Red=50 Green=91 Blue=E9)
|
||||||
|
|
||||||
|
Screen: 261, 39 (less often used)
|
||||||
|
Window: 261, 39 (default)
|
||||||
|
Client: 253, 8 (recommended)
|
||||||
|
Color: A774A9 (Red=A7 Green=74 Blue=A9)
|
||||||
|
*/
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, pix1x-2, pix1y-2, pix1x+2, pix1y+2, %color_check1%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
ControlSend,, {%turnRight% down}, ahk_id %id%
|
||||||
|
Sleep, 140
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu:
|
||||||
|
if (menu_s = 1){
|
||||||
|
gosub, Menu_pixel
|
||||||
|
}
|
||||||
|
if (menu_s = 2){
|
||||||
|
gosub, Menu_time
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_pixel:
|
||||||
|
;ToolTip, Menuing, 100, 100, Screen
|
||||||
|
loop {
|
||||||
|
PixelSearch, x, y, pix2x-2, pix2y-2, pix2x+2, pix2y+2, %color_check2%, 20, Fast RGB
|
||||||
|
If (ErrorLevel != 0) {
|
||||||
|
gosub, PressX
|
||||||
|
sleep %color_2_delay%
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
;ToolTip, Found color 2, 100, 100, Screen
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1200
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
Menu_time:
|
||||||
|
loop, 9{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1700
|
||||||
|
}
|
||||||
|
Sleep, 2000
|
||||||
|
ControlSend,, {Right down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Right up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, %ps_load_time1%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 1000
|
||||||
|
ControlSend,, {Esc down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Esc up}, ahk_id %id%
|
||||||
|
loop, 2 {
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 500
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time2%
|
||||||
|
ControlSend,, {Down down}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
ControlSend,, {Down up}, ahk_id %id%
|
||||||
|
Sleep, 500
|
||||||
|
loop, %menu_loops% {
|
||||||
|
ControlSend,, {%MenuDirect% down}, ahk_id %id%
|
||||||
|
Sleep, 50
|
||||||
|
ControlSend,, {%MenuDirect% up}, ahk_id %id%
|
||||||
|
Sleep, 200
|
||||||
|
}
|
||||||
|
loop, 2{
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
}
|
||||||
|
Sleep, %ps_load_time3%
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
|
||||||
|
return
|
||||||
|
;; General Functions for AHK
|
||||||
|
|
||||||
|
PixelTuning:
|
||||||
|
x_ratio := ps_win_width/640
|
||||||
|
y_ratio := ps_win_height/360
|
||||||
|
pix1x := Floor(pix1x*x_ratio)
|
||||||
|
pix1y := Floor(pix1y*y_ratio)
|
||||||
|
pix2x := Floor(pix2x*x_ratio)
|
||||||
|
pix2y := Floor(pix2y*y_ratio)
|
||||||
|
return
|
||||||
|
|
||||||
|
GrabRemotePlay:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, 0, 0, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
GetClientSize(id, ps_win_width, ps_win_height)
|
||||||
|
gosub, PixelTuning
|
||||||
|
return
|
||||||
|
|
||||||
|
RPwind:
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loop, %remotePlay_id%
|
||||||
|
{
|
||||||
|
id := remotePlay_id%A_Index%
|
||||||
|
WinGetTitle, title, % "ahk_id " id
|
||||||
|
If InStr(title, "PS Remote Play")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
WinGetClass, remotePlay_class, ahk_id %id%
|
||||||
|
WinMove, ahk_id %id%,, -700, -400, 640, 360
|
||||||
|
ControlFocus,, ahk_class %remotePlay_class%
|
||||||
|
WinActivate, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
PixelColorSimple(pc_x, pc_y)
|
||||||
|
{
|
||||||
|
WinGet, remotePlay_id, List, ahk_exe RemotePlay.exe
|
||||||
|
if (remotePlay_id = 0)
|
||||||
|
{
|
||||||
|
MsgBox, PS4 Remote Play not found
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if remotePlay_id
|
||||||
|
{
|
||||||
|
pc_wID := remotePlay_id[0]
|
||||||
|
pc_hDC := DllCall("GetDC", "UInt", pc_wID)
|
||||||
|
pc_fmtI := A_FormatInteger
|
||||||
|
SetFormat, IntegerFast, Hex
|
||||||
|
pc_c := DllCall("GetPixel", "UInt", pc_hDC, "Int", pc_x, "Int", pc_y, "UInt")
|
||||||
|
pc_c := pc_c >> 16 & 0xff | pc_c & 0xff00 | (pc_c & 0xff) << 16
|
||||||
|
pc_c .= ""
|
||||||
|
SetFormat, IntegerFast, %pc_fmtI%
|
||||||
|
DllCall("ReleaseDC", "UInt", pc_wID, "UInt", pc_hDC)
|
||||||
|
return pc_c
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GetClientSize(hWnd, ByRef w := "", ByRef h := "")
|
||||||
|
{
|
||||||
|
VarSetCapacity(rect, 16)
|
||||||
|
DllCall("GetClientRect", "ptr", hWnd, "ptr", &rect)
|
||||||
|
w := NumGet(rect, 8, "int")
|
||||||
|
h := NumGet(rect, 12, "int")
|
||||||
|
}
|
||||||
|
|
||||||
|
Distance(c1, c2)
|
||||||
|
{ ; function by [VxE], return value range = [0, 441.67295593006372]
|
||||||
|
return Sqrt((((c1>>16)-(c2>>16))**2)+(((c1>>8&255)-(c2>>8&255))**2)+(((c1&255)-(c1&255))**2))
|
||||||
|
}
|
||||||
|
|
||||||
|
MenuTest:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
gosub, PixelTuning
|
||||||
|
|
||||||
|
SetKeyDelay, 10
|
||||||
|
|
||||||
|
;get to upper left hand menu
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to options menu
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to Controllers menu
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;get to wireless controller 1p
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change steering controlls
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;change pedal controlls
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressLeft
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;apply settings
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;back to menu
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
;enter world circuits
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 5000
|
||||||
|
|
||||||
|
;enter panam
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
|
||||||
|
;enter race
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 12000
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 2000
|
||||||
|
|
||||||
|
;change gearbox to manual
|
||||||
|
gosub, PressRight
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressDown
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressUp
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
;leave race
|
||||||
|
gosub, PressO
|
||||||
|
gosub, PressX
|
||||||
|
gosub, PressX
|
||||||
|
Sleep, 8000
|
||||||
|
|
||||||
|
;go back to main menu
|
||||||
|
gosub, PressO
|
||||||
|
|
||||||
|
MsgBox, Reverted settings after AFK
|
||||||
|
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_p:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check1 := PixelColorSimple(pix1x, pix1y)
|
||||||
|
;MsgBox, At the screen with [Replay] [Next Race], Press ColorP2
|
||||||
|
c1_alt := true
|
||||||
|
MsgBox, Put this in for color_check1 %color_check1%
|
||||||
|
return
|
||||||
|
|
||||||
|
GetColo_g:
|
||||||
|
gosub, GrabRemotePlay
|
||||||
|
;Screen: 218, 359 (less often used)
|
||||||
|
color_check2 := PixelColorSimple(pix2x, pix2y)
|
||||||
|
c1_alt := false
|
||||||
|
MsgBox, Put this in for color_check2 %color_check2%
|
||||||
|
return
|
||||||
|
|
||||||
|
PSystem:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (SysCheck = 1){
|
||||||
|
ps_load_time1 := 14000
|
||||||
|
ps_load_time2 := 7000
|
||||||
|
ps_load_time3 := 8400
|
||||||
|
}
|
||||||
|
if (SysCheck = 2){
|
||||||
|
ps_load_time1 := 41500
|
||||||
|
ps_load_time2 := 12000
|
||||||
|
ps_load_time3 := 40000
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
MenuSel:
|
||||||
|
Gui, Submit, NoHide
|
||||||
|
if (MenuCheck = 1){
|
||||||
|
menu_s := 1
|
||||||
|
}
|
||||||
|
if (MenuCheck = 2){
|
||||||
|
menu_s := 2
|
||||||
|
}
|
||||||
|
return
|
||||||
|
|
||||||
|
|
||||||
|
PauseLoop:
|
||||||
|
ControlSend,, {%accel% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%nitros% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnLeft% up}, ahk_id %id%
|
||||||
|
ControlSend,, {%turnRight% up}, ahk_id %id%
|
||||||
|
return
|
||||||
|
|
||||||
|
GuiClose:
|
||||||
|
gosub, PauseLoop
|
||||||
|
ExitApp
|
||||||
|
|
||||||
|
^Esc::ExitApp
|
||||||
|
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 467 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 467 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 321 KiB |
Reference in New Issue
Block a user