These forums have been archived and are now read-only.

The new forums are live and can be found at https://forums.eveonline.com/

Issues, Workarounds & Localization

 
  • Topic is locked indefinitely.
 

Eve Windowed mode Auto-Maximize script-o-tweak

Author
Kal'Han
Kador Trade Company
#1 - 2015-06-20 00:03:29 UTC  |  Edited by: Kal'Han
****2015-10-10 - UPDATE for beta launcher Here https://forums.eveonline.com/default.aspx?g=posts&m=6089640#post6089640 ***

Hi all

I was looking in the forum and some place else for a way to launch EVE in windows mode + maximized

there was some posts (quite a few since 2008) for this "feature", and there was no answer to my knowledge.

so after some tinkering I decided to code this myself with powershell loop and a shortcut (.lnk)

Whom does it concern? (who?)

anyone like me, using multiple client/multiple screen but wanting to keep windows taskbar visible and so want to play in windows mode but not lose the corner/egde of the screen because the windows is not fully maximized


What does it do?
it's a powershell script that will launch the Eve laucher and stay there while the laucher run (it runs minimized in the background)
it will detect any process called "exefile.exe" wait for it to appears and then pop, it will go fullscreen
any new exefile will also go fullscreen
this will happen only once and then if you resize, the scrîpt does nothing.
when the launcher is closed the script stop

*note* closing the launcher and relauching it will reset

How does this work ?
you will need to put the PS1 file in your eve root directory (the one containing eve.exe, repair.exe and the folder "launcher")

you will need to right click on this PS1 and "create shortcut" right there in the eve folder

then right click on the shortcut, and change the "Target" by adding BEFORE the content this text :
powershell.exe -executionpolicy remotesigned -File 

(beware the last space)

it should look like this
powershell.exe -executionpolicy remotesigned -File eve.ps1

you can now change the Icon to something pretty, like the Eve Icon, but beware you will have my script, the laucher, then the eve game(s) in the taskbar (I didn't want to hide my script icon and windows, it should be doable, but not sure I want to)

you can rename the shortcut and copy/paste it wherever you want after that



What PS1 File?

as I can't attach a file here, here what you need to copy/paste in a file called eve.ps1

$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
}


No comment in the code, it hook 2 windows lowlevel function to manage windows, loop while waiting for process
you can remove all the "echo" lines, but it does not do anything
cpu usage is null (not sure for vista), but anything running windows 7 should not feel a thing

quick and dirty fix, use it, don't use it, let me know if you have problems, or if you have another solution and I worked on this for 1 hrs and half for nothing :D

Fly safe
Kal'Han
Kador Trade Company
#2 - 2015-07-08 22:45:27 UTC
Updated version after a request and suggesiton by ThrobbingHood TheThird


this will minimize background eve client based on which windows has the focus :
if a eve client has the foreground, all other eve client will minimize, boosting fps
but if another windows has the focus the last eve client displayed stays open

simply replace the code above by this one, launch and installtion method stays the same


$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
}
ThrobbingHood TheThird
Imperial Academy
Amarr Empire
#3 - 2015-07-08 23:05:39 UTC
Script works great :)
Jarno Midumulf
Riders of Sleipnir
Backdoor Crashers
#4 - 2015-07-09 09:54:06 UTC
how will this work with a multiple monitor setup?
Kal'Han
Kador Trade Company
#5 - 2015-07-09 18:09:59 UTC
Jarno Midumulf wrote:
how will this work with a multiple monitor setup?



highly depends on your setup, but right now the 2nd one will minimize any but the ForeGround client

I have 2 screen but only one has all clients displayed on, i use the second one to browse, eft, etc...


if you just want to "maximize", 1rst post script should work fine.


Describe to me your way of setting up, I'll check if i can use other flag like "visible" instead of foreeground.

Treyan Argund
Amok.
Goonswarm Federation
#6 - 2015-07-18 07:29:28 UTC
Slick setup, thanks for the evemail about it. Much appreciated.
Kal'Han
Kador Trade Company
#7 - 2015-10-05 20:42:20 UTC
Now hoping the next launcher will include some of these functions

Also shameless self bump Blink

cheers
Kal'Han
Kador Trade Company
#8 - 2015-10-09 22:14:33 UTC  |  Edited by: Kal'Han
Here is an update for the new launcher, as the name of the program changed a bit

Installation should be followed, but to summarize it will create a shortcut that you will launch in place of the evelauncher

  • create a new text file called EVE.PS1 and paste the code in it, save it and put it in the launcher folder
  • (tips : use microsft+R to run "notepad", and when "saving as..." choose the launhcer folder and remember to chose "all file" instead of "text file" and input the file name "eve.ps1" or use something like notepad++ that doesn't eat the ps1 extension)

  • in the folder, copy the eve.ps1 and right clic "paste shortcut"

  • right clic the shorcut and change the target to this
  • Quote:
    powershell.exe -executionpolicy remotesigned -File eve.ps1


then you can copy the shortcut or move where you like (on the desktop)
and also modify the icon for the shorcut to your liking. I personnaly pinned it in my start menu



code to copy below, updated and commented
(main change is now the ps1 is in the launcher folder, as it is now a separate app from ccp)




# import of windows managment functions from standard win32 API
Add-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...)



also : if you use multilaunch from the new beta launcher, I tested it at various speed but I suggest you put a slow (4-5 sec) and order your account in reverse, as the one on top will be the last one launched until ccp do something about that.

whatever the speed you set all windows will still get maximized, and all non focused one wlil minimize, so it should still work the same