These forums have been archived and are now read-only.
The new forums are live and can be found at https://forums.eveonline.com/
Eve Windowed mode Auto-Maximize script-o-tweak
powershell.exe -executionpolicy remotesigned -File
$sig1=@' [DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); '@ $showWindowAsync = Add-Type -memberDefinition $sig1 -name "Win32ShowWindowAsync" -namespace Win32Functions -passThru $sig2=@' [DllImport("user32.dll", SetLastError=true)] public static extern int GetWindowLong(IntPtr hWnd, int nIndex);'@ $GetWindowLong = Add-Type -memberDefinition $sig2 -name "Win32GetWindowLong" -namespace Win32Functions -passThru $showWindowAsync::ShowWindowAsync((get-process -id $PID).MainWindowHandle, 2)|out-null$app = Start-Process Launcher\Launcher.exe -passthru$pidlist=@{}while ((get-process -id $app.id -ErrorAction SilentlyContinue) -ne $null ){get-process exefile -ErrorAction SilentlyContinue | % { $id=$_.id $hwnd=$_.MainWindowHandle if($pidlist["$id"] -ne 1){ echo "waiting for windows $hwnd" sleep 3 while($hwnd -eq 0){ $hwnd=(get-process -id $id).MainWindowHandle } echo "new handle $hwnd" $style=0 while($style -eq 0) { $style = $GetWindowLong::GetWindowLong($hwnd, -16) sleep 2 echo "waiting ... $hwnd -- $style" } $pidlist["$id"]=1 echo "Go fullscreen $hwnd" $showWindowAsync::ShowWindowAsync($hwnd, 3)|out-null }}echo "Loop"sleep 2}
$sig1=@' [DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); '@ $showWindowAsync = Add-Type -memberDefinition $sig1 -name "Win32ShowWindowAsync" -namespace Win32Functions -passThru $sig2=@' [DllImport("user32.dll", SetLastError=true)] public static extern int GetWindowLong(IntPtr hWnd, int nIndex);'@ $GetWindowLong = Add-Type -memberDefinition $sig2 -name "Win32GetWindowLong" -namespace Win32Functions -passThru Add-Type @" using System; using System.Runtime.InteropServices; public class UserWindows { [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow();}"@ $showWindowAsync::ShowWindowAsync((get-process -id $PID).MainWindowHandle, 2)|out-null$app = Start-Process Launcher\Launcher.exe -passthru$pidlist=@{}$hwndlist=@{}while ((get-process -id $app.id -ErrorAction SilentlyContinue) -ne $null ){get-process exefile -ErrorAction SilentlyContinue | % { $id=$_.id $hwnd=$_.MainWindowHandle if($pidlist["$id"] -ne 1){ echo "waiting for windows $hwnd" sleep 3 while($hwnd -eq 0){ $hwnd=(get-process -id $id).MainWindowHandle } echo "new handle $hwnd" $style=0 while($style -eq 0) { $style = $GetWindowLong::GetWindowLong($hwnd, -16) sleep 2 echo "waiting ... $hwnd -- $style" } $pidlist["$id"]=1 $hwndlist["$hwnd"]=1 echo "Go fullscreen $hwnd" $showWindowAsync::ShowWindowAsync($hwnd, 3)|out-null }else{ $focus=[UserWindows]::GetForegroundWindow() if($hwnd -ne $focus -and $hwndlist["$focus"] -eq 1 ) { $showWindowAsync::ShowWindowAsync($hwnd, 6)|out-null echo "minimize $hwnd" } }}echo "Loop"sleep 2}
# import of windows managment functions from standard win32 APIAdd-Type @" using System; using System.Runtime.InteropServices; public class UserWindows { [DllImport("user32.dll")] public static extern IntPtr GetForegroundWindow(); [DllImport("user32.dll", SetLastError=true)] public static extern int GetWindowLong(IntPtr hWnd, int nIndex); [DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow); }"@#some nifty lists$pidlist=@{} # store pid of each exefile, used to get windows handle$hwndlist=@{} # store evefile.exe windows handle, used to know what to minimize later#reduce the windows running shell#2 = minimize, (0 is hidden, try it yourself)[UserWindows]::ShowWindowAsync((get-process -id $PID).MainWindowHandle, 0)|out-null#launch the eve launcher. launcher may be igored but the scipt will run until the launcher closes# you can comment this line for no launcher at all, but modify also the next line after$app = Start-Process EveLauncher.exe -passthru#if you commented eve launcher, replace following line with : while ($true){while ((get-process -id $app.id -ErrorAction SilentlyContinue) -ne $null ){ #get all process called exefile get-process exefile -ErrorAction SilentlyContinue | % { #get pid and windows handle $id=$_.id $hwnd=$_.MainWindowHandle #if we don't know the pid yet, we don't knows it's handle, here comes the nifty list that is dynamically filled, if a value of "pid" is not set to 1, then we don't know it if($pidlist["$id"] -ne 1){ # waiting 3 sec for eve to initialize then loop untile the process gets a windows handle (that is not instant, so timer plus loop) echo "waiting for windows $hwnd" sleep 3 while($hwnd -eq 0){ $hwnd=(get-process -id $id).MainWindowHandle } # we got a handle \o/ echo "new handle $hwnd" $style=0 #what is that windows style? and we loop again, between handle attribution to real render some loop may occurs while($style -eq 0) { $style = [UserWindows]::GetWindowLong($hwnd, -16) # -16 query the style, if 0 then non existing sleep 2 echo "waiting ... $hwnd -- $style" } #if we are here, the pid is found, the windows handle is found and game window is valid $pidlist["$id"]=1 # storing the "1" flag in the list $hwndlist["$hwnd"]=1 # storing the "1" flag in the list echo "Go fullscreen $hwnd" [UserWindows]::ShowWindowAsync($hwnd, 3)|out-null # actual function that set a windows fullscreen, 3 = fullscren }else{ # Here we know the window, we are getting wich window is on foreground $focus=[UserWindows]::GetForegroundWindow() # if the foreground windows is a game windows and the current exefile we are working on is not the focus if($hwnd -ne $focus -and $hwndlist["$focus"] -eq 1 ) { [UserWindows]::ShowWindowAsync($hwnd, 2)|out-null # 6 = we minimize the windows echo "minimize $hwnd" } } } # small timer the we through the whole process again echo "Loop" sleep 2}# there no management on exefile closing and opening, chance to get the same pid/hwnd are really slim# simply stop the launcher and relaunch the script, that clears the old data and start again with existing windows# I strongly advise against running hidden mode + no launcher. no way to know how much script you are running and you need to kill powershell process.# not pretty (but acceptable if you know what you're doing I guess...)