Created
July 23, 2023 22:12
-
-
Save Matojeje/6366a6cf48d99c93655f107dbc03fffe to your computer and use it in GitHub Desktop.
This AutoHotkey script tracks the duration of Monogolf Challenge mode runs by watching your phone's screen using scrcpy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; Monogolf auto-timer by Mato, version 1.0 | |
; Prerequisites: AutoHotKey v1, ScrCpy on PATH | |
; ===== Info ===== | |
; Single beep means that the run start/end was detected | |
; Very high beep means that you reached a new high score in this session | |
; Double beep means that the window isn't in foreground, so no tracking will happen | |
; Press Esc to stop the script (also possible from the taskbar notification tray) | |
; Make sure to tweak the settings to fit your setup first, especially lines 44 and 73 | |
; ===== Settings ===== | |
; Name of the scrcpy window | |
WindowTitle := "Monogolf" | |
; Whether or not to show the time of each run after it's done | |
ShowTime := true | |
; First, tweak your phone screen crop on line 44 | |
; Then, use AHK WindowSpy to get the Client coordinates of the very end of the red part of the time bar | |
LifeBarEndX := 1360 | |
LifeBarEndY := 6 | |
; Set the loop delay (in milliseconds) to check the pixel color | |
LoopDelay := 50 | |
; Starting high score (in seconds), feel free to modify | |
HiScore := 99999999 | |
; ===== Code ===== | |
ColorRunStart := 0x000000 | |
ColorRunEnd := 0xFFFFFF | |
InGame := false | |
StartTime := A_TickCount | |
if (WinExist(WindowTitle)) { | |
WinActivate, %WindowTitle% | |
} else { | |
; Configure the --crop value according to this: https://github.com/Genymobile/scrcpy/blob/master/doc/video.md#crop | |
; Using the --no-control flag will let you send keys to control your OBS replay buffer | |
; If you don't care about OBS, feel free to leave the flag out, and maybe add -t to show your finger position | |
Run scrcpy --crop=1080:1908:0:246 -m 1440 --rotation=1 --display-buffer=500 --audio-buffer=500 --window-title=Monogolf -b 20M --no-control | |
Sleep, 3000 | |
} | |
; Main loop | |
Loop | |
{ | |
CoordMode, Mouse, Client | |
CoordMode, Pixel, Client | |
if (WinActive(WindowTitle)) { | |
PixelGetColor, PixelColor, LifeBarEndX, LifeBarEndY | |
if (InGame = false) && (PixelColor = ColorRunStart) { | |
InGame := true | |
StartTime := A_TickCount | |
SoundBeep, 1000, 150 | |
} else if (InGame = true) && (PixelColor = ColorRunEnd) { | |
InGame := false | |
SoundBeep, 1500, 150 | |
if (ShowTime = true) { | |
FinalTime := (A_TickCount - StartTime)/1000.0 | |
Sleep, 1000 | |
if (FinalTime <= HiScore) { | |
HiScore := FinalTime | |
SoundBeep, 2000, 300 | |
MsgBox,,, % FinalTime . " || New High Score!!" | |
; You can set the hotkey to save the OBS Replay Buffer of your highscore here | |
; SendInput, {Pause} | |
} else { | |
MsgBox,,, % FinalTime . " || Hi: " . HiScore | |
} | |
} | |
} | |
Sleep, %LoopDelay% | |
} else { | |
SoundBeep, 500, 100 | |
Sleep, 200 | |
SoundBeep, 500, 100 | |
Sleep, 7000 | |
} | |
} | |
; Press Esc to exit the script | |
Esc::ExitApp |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: the time shown in the window is different from the current category rules, so a retime is needed for submitting!