mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-13 23:07:28 +08:00
[+] Execute some command on game idle or on game start
This commit is contained in:
43
AquaMai/UX/RunCommandOnEvents.cs
Normal file
43
AquaMai/UX/RunCommandOnEvents.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using HarmonyLib;
|
||||
using MelonLoader;
|
||||
using Process;
|
||||
|
||||
namespace AquaMai.UX
|
||||
{
|
||||
public class RunCommandOnEvents
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(AdvertiseProcess), "OnStart")]
|
||||
public static void AdvertiseProcessPreStart()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(AquaMai.AppConfig.UX.ExecOnIdle))
|
||||
{
|
||||
Exec(AquaMai.AppConfig.UX.ExecOnIdle);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(EntryProcess), "OnStart")]
|
||||
public static void EntryProcessPreStart()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(AquaMai.AppConfig.UX.ExecOnEntry))
|
||||
{
|
||||
Exec(AquaMai.AppConfig.UX.ExecOnEntry);
|
||||
}
|
||||
}
|
||||
|
||||
private static void Exec(string command)
|
||||
{
|
||||
var process = new System.Diagnostics.Process();
|
||||
process.StartInfo.FileName = "cmd.exe";
|
||||
process.StartInfo.Arguments = "/c " + command;
|
||||
process.StartInfo.UseShellExecute = true;
|
||||
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
|
||||
process.StartInfo.WorkingDirectory = Environment.CurrentDirectory;
|
||||
|
||||
process.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user