Last active
February 21, 2025 19:10
-
-
Save OneNot/0a47d501924d8d4499b52a411f4c8383 to your computer and use it in GitHub Desktop.
A simple script that will: launch Lossless Scaling, auto select a profile, optionally start the game, wait for the game to start, auto-activate scaling, and optionally wait for the game to close to then close LS as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Requires AutoHotkey v2.0 | |
;========== SETTINGS ==========; | |
; Replace with your LS exe filepath | |
losslessScalingExePath := "C:\Program Files (x86)\Steam\steamapps\common\Lossless Scaling\LosslessScaling.exe" | |
; replace with your game exe path OR set to empty string ("") if you do not want the script to start the game | |
gameExePath := "N:\GameLibraries\Steam\SteamLibrary\steamapps\common\Helldivers 2\bin\helldivers2.exe" | |
; put the window title of the game you want detected here. Uses regex. If you don't know what that means, just know that "^game name$" will find a window with exactly "game name" as it's window title, where as "game name" will find the first window with "game title" anywhere in it's title. | |
gameWindowTitle := "^HELLDIVERS™ 2$" | |
; change this to the match the profile you want activated. (1 means first profile after Default and so on...) | |
nthProfileToUse := 1 | |
; true = keep this script running until the game is closed, at which point it will auto-close LS and then itself || false = exit this script after turning on scaling | |
closeLSWithGame := true | |
;==============================; | |
SetTitleMatchMode "RegEx" | |
; Check if Lossless Scaling is already running and if not, start it. Get it's PID. | |
if !(losslessScalingPID := ProcessExist("LosslessScaling.exe")) | |
Run(losslessScalingExePath,,,&losslessScalingPID) | |
; Wait for LS | |
WinWait("ahk_pid " losslessScalingPID) | |
WinRestore("ahk_pid " losslessScalingPID) | |
WinActivate("ahk_pid " losslessScalingPID) | |
WinWaitActive("ahk_pid " losslessScalingPID) | |
; Set coordinate mode to be relative to the active window | |
CoordMode("Mouse", "Client") | |
; Click default profile to set focus there | |
Click(50, 100) | |
; Select profile by simulating Down press nthProfileToUse times | |
Loop nthProfileToUse | |
Send("{Down}") | |
; Wait for focus change | |
Sleep(200) | |
; Minimize Lossless Scaling | |
WinMinimize("ahk_pid " losslessScalingPID) | |
; Start game if gamExePath is given | |
if(gameExePath != "") | |
Run(gameExePath) | |
; Wait for game | |
WinWait(gameWindowTitle) | |
WinWaitActive(gameWindowTitle) | |
; Send CTRL+ALT+S to activate scaling | |
Send("^!s") | |
if(closeLSWithGame) | |
{ | |
; Wait for game to close | |
WinWaitClose(gameWindowTitle) | |
; Close LS if it's still running | |
if ProcessExist(losslessScalingPID) | |
ProcessClose(losslessScalingPID) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment