From 5ae02cd915d05f2a1e22227266954a99a6535786 Mon Sep 17 00:00:00 2001 From: shupershuff <63577525+shupershuff@users.noreply.github.com> Date: Fri, 23 Aug 2024 18:39:38 +1200 Subject: [PATCH] Update D2Loader.ps1 --- D2Loader.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/D2Loader.ps1 b/D2Loader.ps1 index 49c11ee..c9bae4f 100644 --- a/D2Loader.ps1 +++ b/D2Loader.ps1 @@ -1476,7 +1476,7 @@ Function Inventory {#Info screen Write-Host PressTheAnyKey } -Function LoadWindowClass { #Used to get window locations and place them in the same screen locations at launch. Code courtesy of Sir-Wilhelm and Microsoft. +Function Add-WindowType { #Used to get window locations and place them in the same screen locations at launch. Code courtesy of Sir-Wilhelm and Microsoft. if ($Script:WindowClassLoaded -ne $True){ $Script:WindowClassLoaded = $True Add-Type @" @@ -1507,7 +1507,7 @@ Function LoadWindowClass { #Used to get window locations and place them in the s } } Function SaveWindowLocations {# Get Window Location coordinates and save to Accounts.csv - LoadWindowClass + Add-WindowType FormatFunction -indents 2 -text "Saving locations of each open account so that they the windows launch in the same place next time. Assumes you've configured the game to launch in windowed mode." CheckActiveAccounts #If Feature is enabled, add 'WindowXCoordinates' and 'WindowYCoordinates' columns to accounts.csv with empty values. @@ -1568,7 +1568,7 @@ Function SetWindowLocations {# [int]$Width, [int]$Height ) - LoadWindowClass + Add-WindowType $handle = (Get-Process -Id $Id).MainWindowHandle [WindowAPI]::MoveWindow($handle, $x, $y, $Width, $Height, $True) [WindowAPI]::SetForegroundWindow($handle) @@ -1672,7 +1672,7 @@ Function Options { } } ElseIf ($NewOptionValue -eq "r"){ - LoadWindowClass + Add-WindowType CheckActiveAccounts if ($null -eq $Script:ActiveAccountsList){ FormatFunction -text "`nThere are no open games.`nTo reset window positions, you need to launch one or more instances first.`n" -indents 2 -IsWarning @@ -3522,11 +3522,11 @@ Function Processing { } If ($Script:Config.RememberWindowLocations -eq $True){ #If user has enabled the feature to automatically move game Windows to preferred screen locations. if ($Script:AccountChoice.WindowXCoordinates -ne "" -and $Script:AccountChoice.WindowYCoordinates -ne "" -and $Null -ne $Script:AccountChoice.WindowXCoordinates -and $Null -ne $Script:AccountChoice.WindowYCoordinates -and $Script:AccountChoice.WindowWidth -ne "" -and $Script:AccountChoice.WindowHeight -ne "" -and $Null -ne $Script:AccountChoice.WindowWidth -and $Null -ne $Script:AccountChoice.WindowHeight){ #Check if the account has had coordinates saved yet. - $GetLoadWindowClassFunc = $(Get-Command LoadWindowClass).Definition + $GetAdd-WindowTypeFunc = $(Get-Command Add-WindowType).Definition $GetSetWindowLocationsFunc = $(Get-Command SetWindowLocations).Definition $JobID = (Start-Job -ScriptBlock { # Run this in a background job so we don't have to wait for it to complete start-sleep -milliseconds 2024 # We need to wait for about 2 seconds for game to load as if we move it too early, the game itself will reposition the window. Absolute minimum is 420 milliseconds (funnily enough). Delay may need to be a bit higher for people with wooden computers. - Invoke-Expression "function LoadWindowClass {$using:GetLoadWindowClassFunc}" + Invoke-Expression "function Add-WindowType {$using:GetAdd-WindowTypeFunc}" Invoke-Expression "function SetWindowLocations {$using:GetSetWindowLocationsFunc}" SetWindowLocations -x $Using:AccountChoice.WindowXCoordinates -y $Using:AccountChoice.WindowYCoordinates -Width $Using:AccountChoice.WindowWidth -height $Using:AccountChoice.WindowHeight -Id $Using:process.id }).id