; Script by Radsteve ; Forked from Specnr's MoveWorlds-Script #SingleInstance, Force SendMode Input SetWorkingDir, %A_ScriptDir% global count := 0 global McDirectories := [] global rawPIDs := [] global instances := 0 sleep, 500 RunHide(Command) { dhw := A_DetectHiddenWindows DetectHiddenWindows, On Run, %ComSpec%,, Hide, cPid WinWait, ahk_pid %cPid% DetectHiddenWindows, %dhw% DllCall("AttachConsole", "uint", cPid) Shell := ComObjCreate("WScript.Shell") Exec := Shell.Exec(Command) Result := Exec.StdOut.ReadAll() DllCall("FreeConsole") Process, Close, %cPid% Return Result } GetMcDir(pid) { command := Format("powershell.exe $x = Get-WmiObject Win32_Process -Filter \""ProcessId = {1}\""; $x.CommandLine", pid) rawOut := RunHide(command) if (InStr(rawOut, "--gameDir")) { strStart := RegExMatch(rawOut, "P)--gameDir (?:""(.+?)""|([^\s]+))", strLen, 1) return SubStr(rawOut, strStart+10, strLen-10) . "\" } else { strStart := RegExMatch(rawOut, "P)(?:-Djava\.library\.path=(.+?) )|(?:\""-Djava\.library.path=(.+?)\"")", strLen, 1) if (SubStr(rawOut, strStart+20, 1) == "=") { strLen -= 1 strStart += 1 } return StrReplace(SubStr(rawOut, strStart+20, strLen-28) . ".minecraft\", "/", "\") } } GetInstanceTotal() { idx := 1 global rawPIDs WinGet, all, list Loop, %all% { WinGet, pid, PID, % "ahk_id " all%A_Index% WinGetTitle, title, ahk_pid %pid% if (InStr(title, "Minecraft*")) { rawPIDs[idx] := pid idx += 1 } } return rawPIDs.MaxIndex() } GetAllPIDs() { global McDirectories global instances := GetInstanceTotal() ; Generate mcdir and order PIDs Loop, %instances% { mcdir := GetMcDir(rawPIDs[A_Index]) McDirectories[A_Index] := mcdir } } GetAllPIDs() for i, mcdir in McDirectories { saves := mcdir . "saves\" Loop, Files, %saves%*, D { If (InStr(A_LoopFileName, "New World") || InStr(A_LoopFileName, "Speedrun #")) { count := count+1 } } } msgbox, %count% ExitApp