-
Notifications
You must be signed in to change notification settings - Fork 0
/
DS2_MadWatch.ps1
53 lines (45 loc) · 1.94 KB
/
DS2_MadWatch.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# _____ _____ ___ __ __ ___ __ _ _
# | __ \ / ____|__ \ | \/ | | \ \ / / | | | |
# | | | | (___ ) | | \ / | __ _ __| |\ \ /\ / /_ _| |_ ___| |__
# | | | |\___ \ / / | |\/| |/ _` |/ _` | \ \/ \/ / _` | __/ __| '_ \
# | |__| |____) |/ /_ | | | | (_| | (_| | \ /\ / (_| | || (__| | | |
# |_____/|_____/|____| |_| |_|\__,_|\__,_| \/ \/ \__,_|\__\___|_| |_|
# ______
# |______|
#
# DS2_MadWatch 0.1
#
# Process name for Dark Souls 2
$processName = "DarkSoulsII"
# Time interval for checking the process (in seconds)
$interval = 0.1
# Store the last memory usage
$lastMemory = 0
# Continuously check in an infinite loop
while ($true) {
# Get process information
$process = Get-Process | Where-Object { $_.ProcessName -eq $processName } -ErrorAction SilentlyContinue | Select-Object -First 1
# If process exists
if ($process) {
# Convert memory from bytes to MB
$currentMemory = $process.WorkingSet64 / 1MB
# If not the first check, compare memory usage
if ($lastMemory -ne 0) {
# Calculate change in memory
$memoryChange = $currentMemory - $lastMemory
# If increase in memory is more than 5 MB, indicate possible spawn and beep
if ($memoryChange -gt 5) {
Clear-Host
Write-Output "$(Get-Date -Format "HH:mm:ss") - Mad Warrior spawned. Memory increased by $memoryChange MB"
[Console]::Beep(1000, 500) # Beep for 500 milliseconds at 1000 Hz
}
}
# Update last memory usage for next comparison
$lastMemory = $currentMemory
}
else {
Write-Output "Process $processName not found."
}
# Wait for the defined interval before next check
Start-Sleep -Milliseconds (1000 * $interval)
}