Freelancer (2003) Borderless Fullscreen Window Topic is solved

Ask gaming related questions (AHK v1.1 and older)
XHawk87

Freelancer (2003) Borderless Fullscreen Window

01 Mar 2018, 15:13

I am trying to play an old DirectX game, Freelancer (2003), in borderless windowed mode to be more compatible with my multi-monitor setup.

I managed to get it windowed using the command line argument "-windowed". I've also followed these instructions to make it widescreen capable and set it to my primary monitor size. This all works fine.

My problem is now that I can't seem to reposition the window or remove the border style.

My usual go-to script didn't work:

Code: Select all

; Borderless windowed mode - F12
#UseHook On
^!F12::
	WinGet WindowID, ID, A
	WinSet Style, -0xC40000, ahk_id %WindowID%
	WinMove ahk_id %WindowID%, , 0, 0, A_ScreenWidth, A_ScreenHeight
Return
I found that I can't detect hotkeys while the game is running, so I created a launcher script for it that definitely targets the right window and runs these commands on it, but they seem to have no effect:

Code: Select all

#SingleInstance Force

Run "F:\Games\Freelancer\EXE\freelancer.exe" -windowed, F:\Games\Freelancer\EXE,, FreelancerPID

WinWait ahk_pid %FreelancerPID%,, 5

if (ErrorLevel = 1) {
    ExitApp
}

WinGet WindowID, ID, ahk_pid %FreelancerPID%
WinActivate ahk_id %WindowID%
WinSet Style, -0xC40000, ahk_id %WindowID%
WinMove ahk_id %WindowID%, , 0, 0, 1920, 1080

WinWaitClose ahk_id %WindowID%

ExitApp

#IfWinActive ahk_exe freelancer.exe

#IfWinActive
Does anyone have any thoughts on how I can do this?
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Freelancer (2003) Borderless Fullscreen Window

01 Mar 2018, 15:37

I've had luck using -0xC00000, though since I was launching via Steam URL, I couldn't use the PID. You may also want to double/triple-check that the PID is the correct one for the window. I use the following setup:

Code: Select all

; gamePath is just the path to the exe
; gameWin is a WinTitle format string, using both (and only) ahk_class and ahk_exe
if(!winExist(gameWin)){
    run,% gamePath
    winWait,% gameWin
}
winSet,style,-0xC00000,% gameWin
; when I did this, it was no longer perfectly fitting my screen, so I added the next bit; it compensates for if there multiple screens, so you could also just use winMove with a_screenWidth and a_screenHeight
sysGet,mon,monitor,% getMonitorIndexFromWindow(gameWin)
winMove,% gameWin,,monLeft,monTop,monRight-monLeft,monBottom-monTop
exitApp

; https://autohotkey.com/board/topic/69464-how-to-determine-a-window-is-in-which-monitor/?p=440355
getMonitorIndexFromWindow(winTitle:="A",byref monRet:=""){
    winGet,hwnd,id,% winTitle
    varSetCapacity(monInfo,40),numPut(40, monInfo),mon:=[]
    
    if(monHandle:=dllCall("MonitorFromWindow","UInt",hwnd,"UInt",0x2)) 
        && dllCall("GetMonitorInfo","UInt",monHandle,"UInt",&monInfo){
        loop 4
            mon[a_index]:=numGet(monInfo,4*a_index,"Int")

        sysGet,monCount,monitorCount
        loop % monCount
        {
            sysGet,iMon,Monitor,% a_index

            ; Compare location to determine the monitor index.
            if(mon[1]=iMonLeft && mon[2]=iMonTop && mon[3]=iMonRight && mon[4]=iMonBottom){
                monIndex:=a_index
                break
            }
        }
    }
    if(monRet)
        monRet:=mon
    
    return monIndex?monIndex:1 
}
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
XHawk87
Posts: 2
Joined: 01 Mar 2018, 15:15

Re: Freelancer (2003) Borderless Fullscreen Window

01 Mar 2018, 17:41

Hi Masonjar13

Thanks for responding
Masonjar13 wrote:I've had luck using -0xC00000
I have now tried this style code, unfortunately it also seemingly has no effect on the window.
Masonjar13 wrote:You may also want to double/triple-check that the PID is the correct one for the window.
I have now triple-checked, it is definitely the right window. I used WinGetTitle to display the window and it matched what I was seeing, and got an output of the PID and checked it against the window in task manager.
Masonjar13 wrote:

Code: Select all

; gameWin is a WinTitle format string, using both (and only) ahk_class and ahk_exe
I tried switching all of the commands to use the ahk_exe found for the window using Window Spy, but they still have no effect.

Is there anything else I can try?
User avatar
Masonjar13
Posts: 1555
Joined: 20 Jul 2014, 10:16
Location: Не Россия
Contact:

Re: Freelancer (2003) Borderless Fullscreen Window

01 Mar 2018, 20:27

You may try using WinGet,Style to see what it does and doesn't already have in terms of possible borders. You should also make sure the script is running as admin. Besides that, I'm not sure. I don't actually have the game, so I can't test.
OS: Windows 10 Pro | Editor: Notepad++
My Personal Function Library | Old Build - New Build
XHawk87
Posts: 2
Joined: 01 Mar 2018, 15:15

Re: Freelancer (2003) Borderless Fullscreen Window  Topic is solved

01 Mar 2018, 20:59

Thanks, Masonjar13. Admin mode did the trick.

Here is my final script, if anyone is searching this issue:

Code: Select all

#SingleInstance Force

If (!A_IsAdmin) {
	Run *runas "%A_ScriptFullPath%"
	return
}

Run "F:\Games\Freelancer\EXE\freelancer.exe" -windowed, F:\Games\Freelancer\EXE,, FreelancerPID

WinWait ahk_pid %FreelancerPID%,, 5

if (ErrorLevel = 1) {
    ExitApp
}

WinGet WindowID, ID, ahk_pid %FreelancerPID%

WinActivate ahk_id %WindowID%
WinSet Style, -0xC00000, ahk_id %WindowID%
WinMove ahk_id %WindowID%, , 0, 0, 1920, 1080

WinWaitClose ahk_id %WindowID%

ExitApp

#IfWinActive ahk_exe freelancer.exe

#IfWinActive

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: yuu453 and 70 guests