Skip to content

Instantly share code, notes, and snippets.

@OneNot
Last active February 21, 2025 19:10
Show Gist options
  • Select an option

  • Save OneNot/0a47d501924d8d4499b52a411f4c8383 to your computer and use it in GitHub Desktop.

Select an option

Save OneNot/0a47d501924d8d4499b52a411f4c8383 to your computer and use it in GitHub Desktop.

Revisions

  1. OneNot revised this gist Feb 21, 2025. No changes.
  2. OneNot revised this gist Feb 21, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion AutoLosslessScalingForUndetectedGames.ahk
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ losslessScalingExePath := "C:\Program Files (x86)\Steam\steamapps\common\Lossles
    ; 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" in it's window title, where as "game name" will find the first window with "game title" anywhere in it's title.
    ; 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...)
  3. OneNot revised this gist Feb 21, 2025. 2 changed files with 68 additions and 52 deletions.
    68 changes: 68 additions & 0 deletions AutoLosslessScalingForUndetectedGames.ahk
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,68 @@
    #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" in 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)
    }
    52 changes: 0 additions & 52 deletions AutoLosslessScalingHelldivers2.ahk
    Original file line number Diff line number Diff line change
    @@ -1,52 +0,0 @@
    #Requires AutoHotkey v2.0

    losslessScalingExePath := "C:\Program Files (x86)\Steam\steamapps\common\Lossless Scaling\LosslessScaling.exe" ; Replace with your LS exe filepath
    gameExePath := "" ; paste game exe filepath here to have this script also start up the game. If this is left empty, it is assumed that you will be launching the game yourself or by other means.
    closeLSWithGame := false ; change to true to auto close LS after game closes (otherwise, this script exits after turning on scaling)
    nthProfileToUse := 1 ; change this to the match the profile you want activated. (1 means first profile after Default and so on...)

    ; Check if Lossless Scaling is already running and if not, start it. Get it's PID.
    if !(pid := ProcessExist("LosslessScaling.exe"))
    Run(losslessScalingExePath,,,&pid)

    ; Wait for LS
    WinWait("ahk_pid " pid)
    WinRestore("ahk_pid " pid)
    WinActivate("ahk_pid " pid)
    WinWaitActive("ahk_pid " pid)

    ; 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 " pid)

    if(gameExePath != "")
    Run(gameExePath)

    ; Wait for HELLDIVERS™ 2
    WinWait("HELLDIVERS™ 2")
    WinWaitActive("HELLDIVERS™ 2")

    ; Send CTRL+ALT+S to activate scaling
    Send("^!s")

    if(closeLSWithGame)
    {
    ; Wait for HELLDIVERS™ 2 to close
    WinWaitClose("HELLDIVERS™ 2")

    ; Close LS if it's still running
    if ProcessExist(pid)
    ProcessClose(pid)
    }
  4. OneNot revised this gist Feb 21, 2025. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions AutoLosslessScalingHelldivers2.ahk
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    #Requires AutoHotkey v2.0

    losslessScalingExePath := "C:\Program Files (x86)\Steam\steamapps\common\Lossless Scaling\LosslessScaling.exe"
    gameExePath := "" ; paste game exe path here to have this script also start up the game
    losslessScalingExePath := "C:\Program Files (x86)\Steam\steamapps\common\Lossless Scaling\LosslessScaling.exe" ; Replace with your LS exe filepath
    gameExePath := "" ; paste game exe filepath here to have this script also start up the game. If this is left empty, it is assumed that you will be launching the game yourself or by other means.
    closeLSWithGame := false ; change to true to auto close LS after game closes (otherwise, this script exits after turning on scaling)
    nthProfileToUse := 1 ; change this to the match the profile you want activated. (1 means first profile after Default and so on...)

  5. OneNot revised this gist Feb 21, 2025. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions AutoLosslessScalingHelldivers2.ahk
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    losslessScalingExePath := "C:\Program Files (x86)\Steam\steamapps\common\Lossless Scaling\LosslessScaling.exe"
    gameExePath := "" ; paste game exe path here to have this script also start up the game
    closeLSWithGame := false ; change to true to auto close LS after game closes (otherwise, this script exits after turning on scaling)

    nthProfileToUse := 1 ; change this to the match the profile you want activated. (1 means first profile after Default and so on...)

    ; Check if Lossless Scaling is already running and if not, start it. Get it's PID.
    if !(pid := ProcessExist("LosslessScaling.exe"))
    @@ -21,8 +21,9 @@ CoordMode("Mouse", "Client")
    ; Click default profile to set focus there
    Click(50, 100)

    ; Select profile (adjust the number in {Down x} to change selection)
    Send("{Down 1}")
    ; Select profile by simulating Down press nthProfileToUse times
    Loop nthProfileToUse
    Send("{Down}")

    ; Wait for focus change
    Sleep(200)
  6. OneNot revised this gist Feb 21, 2025. 1 changed file with 13 additions and 6 deletions.
    19 changes: 13 additions & 6 deletions AutoLosslessScalingHelldivers2.ahk
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,9 @@
    #Requires AutoHotkey v2.0

    losslessScalingExePath := "C:\Program Files (x86)\Steam\steamapps\common\Lossless Scaling\LosslessScaling.exe"
    gameExePath := "" ; paste game exe path here to have this script also start up the game
    closeLSWithGame := false ; change to true to auto close LS after game closes (otherwise, this script exits after turning on scaling)


    ; Check if Lossless Scaling is already running and if not, start it. Get it's PID.
    if !(pid := ProcessExist("LosslessScaling.exe"))
    @@ -27,7 +30,8 @@ Sleep(200)
    ; Minimize Lossless Scaling
    WinMinimize("ahk_pid " pid)

    ;Run("gameExePath") ; launch game ;Uncomment this line and replace gameExePath to use this script as a launcher
    if(gameExePath != "")
    Run(gameExePath)

    ; Wait for HELLDIVERS™ 2
    WinWait("HELLDIVERS™ 2")
    @@ -36,9 +40,12 @@ WinWaitActive("HELLDIVERS™ 2")
    ; Send CTRL+ALT+S to activate scaling
    Send("^!s")

    ; Wait for HELLDIVERS™ 2 to close
    WinWaitClose("HELLDIVERS™ 2")
    if(closeLSWithGame)
    {
    ; Wait for HELLDIVERS™ 2 to close
    WinWaitClose("HELLDIVERS™ 2")

    ; Close LS if it's still running
    if ProcessExist(pid)
    ProcessClose(pid)
    ; Close LS if it's still running
    if ProcessExist(pid)
    ProcessClose(pid)
    }
  7. OneNot revised this gist Feb 21, 2025. No changes.
  8. OneNot revised this gist Feb 21, 2025. 1 changed file with 39 additions and 15 deletions.
    54 changes: 39 additions & 15 deletions AutoLosslessScalingHelldivers2.ahk
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,44 @@
    #Requires AutoHotkey v2.0

    losslessScalingExePath := "C:\Program Files (x86)\Steam\steamapps\common\Lossless Scaling\LosslessScaling.exe"

    Run, %losslessScalingExePath%,,,pid ;run it
    Process, Wait, %pid% ;wait for process
    WinActivate, ahk_pid %pid% ;set active
    WinWaitActive, ahk_pid %pid% ;wait for active
    CoordMode, Mouse, Relative ;set coordinates to relative to window
    Click, 50, 100 ;click default profile to set focus there
    Send, {Down 1} ;select the nth profile after Default, where n = number after "Down" e.g. {Down 2} to select second profile after Default
    Sleep, 200 ;wait for focus to move / profile to switch (probably not needed, but just in case)
    WinMinimize, ahk_pid %pid% ;minimize LS
    ; Check if Lossless Scaling is already running and if not, start it. Get it's PID.
    if !(pid := ProcessExist("LosslessScaling.exe"))
    Run(losslessScalingExePath,,,&pid)

    ; Wait for LS
    WinWait("ahk_pid " pid)
    WinRestore("ahk_pid " pid)
    WinActivate("ahk_pid " pid)
    WinWaitActive("ahk_pid " pid)

    ; 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 (adjust the number in {Down x} to change selection)
    Send("{Down 1}")

    ; Wait for focus change
    Sleep(200)

    ; Minimize Lossless Scaling
    WinMinimize("ahk_pid " pid)

    ;Run("gameExePath") ; launch game ;Uncomment this line and replace gameExePath to use this script as a launcher

    ; Wait for HELLDIVERS™ 2
    WinWait("HELLDIVERS™ 2")
    WinWaitActive("HELLDIVERS™ 2")

    ;Run, "gameExePath" ; launch game ;Uncomment this line and fill in gameExePath to use this script as a launcher
    ; Send CTRL+ALT+S to activate scaling
    Send("^!s")

    WinWaitActive, HELLDIVERS™ 2 ;wait for game window to be active
    Sleep, 5000 ;wait extra 5s just in case
    Send, ^!s ; send CTRL+ALT+S to activate scaling
    ; Wait for HELLDIVERS™ 2 to close
    WinWaitClose("HELLDIVERS™ 2")

    ;WinWaitClose, HELLDIVERS™ 2 ;uncomment this and next line to wait for Helldivers 2 to close and then auto-close Lossless Scaling
    ;Process, Close, %pid%
    ; Close LS if it's still running
    if ProcessExist(pid)
    ProcessClose(pid)
  9. OneNot revised this gist Feb 20, 2025. No changes.
  10. OneNot revised this gist Feb 20, 2025. No changes.
  11. OneNot created this gist Feb 20, 2025.
    20 changes: 20 additions & 0 deletions AutoLosslessScalingHelldivers2.ahk
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    losslessScalingExePath := "C:\Program Files (x86)\Steam\steamapps\common\Lossless Scaling\LosslessScaling.exe"

    Run, %losslessScalingExePath%,,,pid ;run it
    Process, Wait, %pid% ;wait for process
    WinActivate, ahk_pid %pid% ;set active
    WinWaitActive, ahk_pid %pid% ;wait for active
    CoordMode, Mouse, Relative ;set coordinates to relative to window
    Click, 50, 100 ;click default profile to set focus there
    Send, {Down 1} ;select the nth profile after Default, where n = number after "Down" e.g. {Down 2} to select second profile after Default
    Sleep, 200 ;wait for focus to move / profile to switch (probably not needed, but just in case)
    WinMinimize, ahk_pid %pid% ;minimize LS

    ;Run, "gameExePath" ; launch game ;Uncomment this line and fill in gameExePath to use this script as a launcher

    WinWaitActive, HELLDIVERS™ 2 ;wait for game window to be active
    Sleep, 5000 ;wait extra 5s just in case
    Send, ^!s ; send CTRL+ALT+S to activate scaling

    ;WinWaitClose, HELLDIVERS™ 2 ;uncomment this and next line to wait for Helldivers 2 to close and then auto-close Lossless Scaling
    ;Process, Close, %pid%