diff --git a/src/Extreme Soft/OSTaskManager/OSTaskManager.fsproj b/src/Extreme Soft/OSTaskManager/OSTaskManager.fsproj new file mode 100644 index 0000000..b7bb3ac --- /dev/null +++ b/src/Extreme Soft/OSTaskManager/OSTaskManager.fsproj @@ -0,0 +1,16 @@ + + + + Exe + net5.0 + + + + + + + + + + + diff --git a/src/Extreme Soft/OSTaskManager/OSTaskManager.sln b/src/Extreme Soft/OSTaskManager/OSTaskManager.sln new file mode 100644 index 0000000..30e5959 --- /dev/null +++ b/src/Extreme Soft/OSTaskManager/OSTaskManager.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.31129.286 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "OSTaskManager", "OSTaskManager.fsproj", "{CAAA271A-B23A-41E2-AE4E-4EF846AA199A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CAAA271A-B23A-41E2-AE4E-4EF846AA199A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CAAA271A-B23A-41E2-AE4E-4EF846AA199A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CAAA271A-B23A-41E2-AE4E-4EF846AA199A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CAAA271A-B23A-41E2-AE4E-4EF846AA199A}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {56079CA1-154C-4679-8410-80D59FDA600E} + EndGlobalSection +EndGlobal diff --git a/src/Extreme Soft/OSTaskManager/Program.fs b/src/Extreme Soft/OSTaskManager/Program.fs new file mode 100644 index 0000000..68e24ad --- /dev/null +++ b/src/Extreme Soft/OSTaskManager/Program.fs @@ -0,0 +1,43 @@ +open System +open System.Management +open System.Diagnostics +open System.IO + +let getSysData () = + let wql = ObjectQuery("SELECT * FROM Win32_OperatingSystem"); + let searcher = new ManagementObjectSearcher(wql); + let results = searcher.Get(); + let arrResults = Array.create 1 null + results.CopyTo(arrResults, 0) + arrResults + +let limpopoPath = @$"{Environment.CurrentDirectory}\..\..\..\..\..\Games\Limpopo\limpopo.exe" + +[] +let main _ = + let loop = async { + while true do + let! sleep = Async.Sleep(3000); + + let data = getSysData() + data + |> Array.iter(fun d -> + if d <> null + then + let total = Convert.ToDouble(d.["TotalVisibleMemorySize"]) + let free = Convert.ToDouble(d.["FreePhysicalMemory"]) + if free / total < 0.5 + then + + let info = ProcessStartInfo(limpopoPath, "\q"); + info.CreateNoWindow <- false; + info.UseShellExecute <- true; + let proc = Process.Start info + () + ) + () + } + + loop |> Async.RunSynchronously + + 0 \ No newline at end of file