Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/Extreme Soft/OSTaskManager/OSTaskManager.fsproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<Compile Include="Program.fs" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="System.Management" Version="5.0.0" />
</ItemGroup>

</Project>
25 changes: 25 additions & 0 deletions src/Extreme Soft/OSTaskManager/OSTaskManager.sln
Original file line number Diff line number Diff line change
@@ -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
43 changes: 43 additions & 0 deletions src/Extreme Soft/OSTaskManager/Program.fs
Original file line number Diff line number Diff line change
@@ -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"

[<EntryPoint>]
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