Skip to content

Commit a0f5274

Browse files
authored
Update and rename Lossless_Scaling_start_v2.ahk to Lossless_Scaling_Manager.ahk
1 parent 64e2fdb commit a0f5274

File tree

2 files changed

+57
-29
lines changed

2 files changed

+57
-29
lines changed

Other/Lossless_Scaling_Manager.ahk

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#Requires AutoHotkey v2.0
2+
#SingleInstance Force
3+
4+
; ---------- Config ----------
5+
LSPath := "C:\Program Files\Lossless Scaling\LosslessScaling.exe" ; update if different
6+
MinDelayMs := 800
7+
8+
; ---------- Helpers ----------
9+
IsAdmin() => DllCall("shell32\IsUserAnAdmin", "Int")
10+
EnsureAdmin() {
11+
if IsAdmin()
12+
return
13+
try Run('*RunAs "' A_AhkPath '" "' A_ScriptFullPath '" ' A_Args.Join(" "))
14+
ExitApp
15+
}
16+
EnsureAdmin()
17+
18+
MinimizeLS() {
19+
try {
20+
WinWait("ahk_exe LosslessScaling.exe",, 2)
21+
WinMinimize("ahk_exe LosslessScaling.exe")
22+
}
23+
}
24+
25+
StartLS() {
26+
global LSPath, MinDelayMs
27+
if !FileExist(LSPath)
28+
throw Error("LSPath not found: " LSPath)
29+
Run(LSPath,, "UseErrorLevel")
30+
Sleep(MinDelayMs)
31+
MinimizeLS()
32+
}
33+
34+
StopLS() {
35+
try ProcessClose("LosslessScaling.exe")
36+
}
37+
38+
ToggleLS() {
39+
if ProcessExist("LosslessScaling.exe")
40+
StopLS()
41+
else
42+
StartLS()
43+
}
44+
45+
; ---------- Dispatch ----------
46+
cmd := (A_Args.Length ? StrLower(A_Args[1]) : "toggle")
47+
try {
48+
switch cmd {
49+
case "start": StartLS()
50+
case "stop", "close": StopLS()
51+
case "toggle": ToggleLS()
52+
default:
53+
MsgBox("Usage: " A_ScriptName " [start|stop|toggle]")
54+
}
55+
} catch Error as err {
56+
MsgBox("Error: " err.Message)
57+
}

Other/Lossless_Scaling_start_v2.ahk

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)