Skip to content

Instantly share code, notes, and snippets.

@bls1999
Created February 8, 2021 07:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bls1999/3b1ab297582c10bd3a88f58b796d8ee9 to your computer and use it in GitHub Desktop.
Save bls1999/3b1ab297582c10bd3a88f58b796d8ee9 to your computer and use it in GitHub Desktop.
An AutoHotkey script intended to open five Platform Racing 2 windows in an organized fashion for the purpose of simming/macroing experience points.
#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
; Get/set config
IniRead, pr2Path, pr2sim.ini, location, path
if (!pr2Path or !FileExist(pr2Path)) { ; If settings don't already exist
FileSelectFile, pr2Path, 3, , Select the PR2 Executable, Platform Racing 2 (*.exe)
if (ErrorLevel) {
Exit, 0
}
; Check to make sure it's a valid file
pr2Path := Trim(pr2Path)
if (!FileExist(pr2Path) or !InStr(pr2Path, ".exe")) {
MsgBox, , Error, Error: Invalid file specified. Make sure you're selecting the official Platform Racing 2 executable (.exe) file.
Exit, 0
}
IniWrite, %pr2Path%, pr2sim.ini, location, path
}
; Run one PR2 for reference
Run, %pr2Path%
WinWaitActive, Adobe Flash Player 32
WinGetPos,,, pr2BaseWidth, pr2BaseHeight
; Scale sizing
scalePerc := A_ScreenWidth / (pr2BaseWidth * 3)
pr2Width := pr2BaseWidth * scalePerc
pr2Height := pr2BaseHeight * scalePerc
; Reduce if larger than height
if (pr2Height * 2 > A_ScreenHeight) {
scalePerc := A_ScreenHeight / (pr2Height * 2)
pr2Width := pr2Width * scalePerc
pr2Height := pr2Height * scalePerc
}
; Round to nearest integer
pr2Width := Round(pr2Width)
pr2Height := Round(pr2Height)
; Open PR2s
Loop, 5
{
if (A_Index > 1) {
Run, %pr2Path%
WinWaitActive, Adobe Flash Player 32
}
WinSetTitle, PR2 Sim Window #%A_Index%
switch (A_Index) {
case 1:
WinMove,,, 0, 0, pr2Width, pr2Height
case 2:
WinMove,,, 0, A_ScreenHeight / 2, pr2Width, pr2Height
case 3:
WinMove,,, A_ScreenWidth / 3, 0, pr2Width, pr2Height
case 4:
WinMove,,, A_ScreenWidth / 3, A_ScreenHeight / 2, pr2Width, pr2Height
case 5:
WinMove,,, A_ScreenWidth / 3 * 2, 0, pr2Width, pr2Height
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment