True windowed fullscreen (autohotkey script included)

General discussions about the games by Egosoft including X-BTF, XT, X², X³: Reunion, X³: Terran Conflict and X³: Albion Prelude.

Moderator: Moderators for English X Forum

slomer
Posts: 13
Joined: Mon, 13. Aug 12, 02:05

True windowed fullscreen (autohotkey script included)

Post by slomer »

Hello all. I have been reading these forums as I learn to play X3:TC and although the game is about as wonky as they come I am addicted. I prefer to play my games in windowed full screen and although windowed mode is an option it doesn't quite work right on my Win 7 x64 setup. It has a title bar that it moves off screen and since it doesn't extend to the bottom it doesn't cover the taskbar. Full screen alt tabs poorly. So to fix this.. here is an autohotkey script. If you aren't familiar with autohotkey I highly recommend the program. Running this script you simply hit f12 while in the X3 game running in it's wonky windowed mode and it should then work the way you would expect a fullscreen windowed game to work. If you hit f12 again it will return to wonky window mode. (note sure why you would want to but there ya go).

Code: Select all

F12::
WinGet, TempWindowID, ID, A
If (WindowID != TempWindowID)
{
  WindowID:=TempWindowID
  WindowState:=0
}
If (WindowState != 1)
{
  WinGetPos, WinPosX, WinPosY, WindowWidth, WindowHeight, ahk_id %WindowID%
  WinSet, Style, ^0xC00000, ahk_id %WindowID%
  WinMove, ahk_id %WindowID%, , 0, 0, ScreenWidth, ScreenHeight
}
Else
{
  WinSet, Style, ^0xC00000, ahk_id %WindowID%
  WinMove, ahk_id %WindowID%, , WinPosX, WinPosY, WindowWidth, WindowHeight
}
WindowState:=!WindowState
return
Update: While the above code will work regardless of your resolution it appears autohotkey may have a hard time setting the correct screenHeight so if you know what resolution you will be running it is more reliable to hardcode those numbers. This will avoid issues such as the subtitles being cut short or line doubling making text a bit ugly due to it setting the window slightly bigger than your actual resolution.

For example, I run 1920x1080 as my resolution so...
instead of:

Code: Select all

WinMove, ahk_id %WindowID%, , 0, 0, ScreenWidth, ScreenHeight
I now use:

Code: Select all

WinMove, ahk_id %WindowID%, , 0, 0, 1920, 1080
resulting in this:

Code: Select all

F12::
WinGet, TempWindowID, ID, A
If (WindowID != TempWindowID)
{
  WindowID:=TempWindowID
  WindowState:=0
}
If (WindowState != 1)
{
  WinGetPos, WinPosX, WinPosY, WindowWidth, WindowHeight, ahk_id %WindowID%
  WinSet, Style, ^0xC00000, ahk_id %WindowID%
  WinMove, ahk_id %WindowID%, , 0, 0,1920, 1080
}
Else
{
  WinSet, Style, ^0xC00000, ahk_id %WindowID%
  WinMove, ahk_id %WindowID%, , WinPosX, WinPosY, WindowWidth, WindowHeight
}
WindowState:=!WindowState
return
Last edited by slomer on Sun, 19. Aug 12, 19:46, edited 4 times in total.
Solomon Short
Posts: 797
Joined: Wed, 25. Mar 09, 07:00
x4

Post by Solomon Short »

I was able to live with the extraneous desktop space below the window on XP, so what I'm wondering is if this fixes the missing lines issue on Win7?

If so I'll have to look into getting AHK.

Edit:
To answer my own question, it does fix my issue with the window height being compressed by the border & thus losing lines from the game display (making menus ugly & being a general irritant).

Thank you, your fix is much appreciated.
Last edited by Solomon Short on Mon, 13. Aug 12, 04:00, edited 1 time in total.
User avatar
StarSword
Posts: 2963
Joined: Fri, 31. Dec 10, 02:04
x3tc

Post by StarSword »

I think this belongs in the scripts and mods forum.
TC unless otherwise specified. | Find me on Steam! | My X3TC Links | X and X Rebirth @ TVTropes
slomer
Posts: 13
Joined: Mon, 13. Aug 12, 02:05

Post by slomer »

StarSword wrote:I think this belongs in the scripts and mods forum.
Well, it technically isn't a script or a mod for the game but if the moderators feel it is better placed there I am fine with that. I looked around to find an existing solution to this issue and all I found were some old posts with people asking for a solution and not finding one so I figured I'd share what I came up with instead.
Coreblimey
Posts: 1170
Joined: Wed, 25. Aug 10, 17:48
x3tc

Post by Coreblimey »

Actually, if it belongs anywhere, it is the Tech & Support Forum where people who are having issues with windowed mode can read it.

But the final decision is a Moderator's, so I think it's best left at that. :)
If it doesn't work, give it a kick. If that doesn't fix it hit it with a hammer. If it still doesn't work, USE A BIGGER HAMMER!!!

Unknown Sector..... That's what you get for using Bing instead of Google!
slomer
Posts: 13
Joined: Mon, 13. Aug 12, 02:05

Post by slomer »

@Solomon Short.. Happy to help
Alan Phipps
Moderator (English)
Moderator (English)
Posts: 31630
Joined: Fri, 16. Apr 04, 19:21
x4

Post by Alan Phipps »

I think this is probably generic code for use with any window-enabled X-game so far and so is probably best left here for now.

I also think that if this leaves the game vanilla (which it obviously does) and has no untoward effects (to be tested by users) then it would merit being offered as a linked entry in the appropriate Resources and Guides Sticky listing.
A dog has a master; a cat has domestic staff.
slomer
Posts: 13
Joined: Mon, 13. Aug 12, 02:05

Post by slomer »

Alan Phipps wrote:I think this is probably generic code for use with any window-enabled X-game so far and so is probably best left here for now.

I also think that if this leaves the game vanilla (which it obviously does) and has no untoward effects (to be tested by users) then it would merit being offered as a linked entry in the appropriate Resources and Guides Sticky listing.
I left it generic specifically for that reason. It can be made to work automatically with specific games instead of needing the hotkey but then if a class id is changed or a new game launches it would need to be maintained. The way it is written it should work with any resolution, version of windows, and windowed X game without worrying about going out of date. The only downside to this version is that you can only adjust one game window at a time. Unless you are super hardcore and plan to run multiple copies of X games at the same time that shouldn't matter much.
User avatar
Axeface
Posts: 3029
Joined: Fri, 18. Nov 05, 00:41
x4

Post by Axeface »

Brilliant! I've wanted one of these for x for ages, thanks!
slomer
Posts: 13
Joined: Mon, 13. Aug 12, 02:05

Post by slomer »

Axeface wrote:Brilliant! I've wanted one of these for x for ages, thanks!
You are welcome. As much help as these forums have been, and as fun as it has been to read some of the stories (especially SLUG's DiDs) I am glad to help a few people in return.
slomer
Posts: 13
Joined: Mon, 13. Aug 12, 02:05

Update

Post by slomer »

I realized after playing a while that this was cutting off about 5 pixels at the bottom of my screen and making subtitles harder to see. For some reason on my windows 7 x64 box autohotkey isn't setting screenHeight correctly to 1080. It looks like if you know what resolution you will be running it is more reliable to manually set the width and height.

For example:

Instead of:

Code: Select all

WinMove, ahk_id %WindowID%, , 0, 0, ScreenWidth, ScreenHeight 
I now use:

Code: Select all

WinMove, ahk_id %WindowID%, , 0, 0, 1920, 1080
I will update the original post as well.[/code]
User avatar
Da_Junka
Posts: 1072
Joined: Sat, 15. Mar 03, 20:40
x3tc

Post by Da_Junka »

I'm not accustomed to scripts, how do you make this work?
~Intel i5 2500K ~ Nvidia GTX 670 ~ Z77 chipset ~ 16 gig Vengence ~Win 7 64bit ~
Coreblimey
Posts: 1170
Joined: Wed, 25. Aug 10, 17:48
x3tc

Post by Coreblimey »

Just copy the script to a text file and give it a name that you can remember. Change the '.txt' suffix of the file to '.ahk' (without the single quotes). This will associate the file to AutoHotKey. Double click on the file. This will start AHK which will run the script automatically. Start your game in windowed mode and then just press 'F12' and the window will be adjusted. :)
If it doesn't work, give it a kick. If that doesn't fix it hit it with a hammer. If it still doesn't work, USE A BIGGER HAMMER!!!

Unknown Sector..... That's what you get for using Bing instead of Google!
Solomon Short
Posts: 797
Joined: Wed, 25. Mar 09, 07:00
x4

Post by Solomon Short »

Edit: Ninja'd, but I'll leave my version here anyway

It's a script for an external macroing utility known as Autohotkey.

After you install that, your right-click/context menu in Windows Explorer should have a new entry "AutoHotKey Script" under "New" when right-clicking on empty-space on the desktop or in a folder.

You want to right-click on the newly created script & select "Edit Script", then copy & paste the text from inside the last "Code" box in the OP into it.

Then if you run the script whenever you play an X3 (or any other game where maximising the window in this way needs to be done), hitting [F12] will toggle between maximised & non-maximised.

I would note that the 1st line "F12::" is the one specifying use of [F12], so if like me you use it in the game (I have save & load on it), you need to edit that line (I changed it "AppsKey & NumPadSub::" for my own use, the AutoHotKey help docs were actually useful).
User avatar
Da_Junka
Posts: 1072
Joined: Sat, 15. Mar 03, 20:40
x3tc

Post by Da_Junka »

Nice one. Thanks guys. :)
~Intel i5 2500K ~ Nvidia GTX 670 ~ Z77 chipset ~ 16 gig Vengence ~Win 7 64bit ~
Lazerius
Posts: 539
Joined: Thu, 6. Apr 06, 22:44
x4

Post by Lazerius »

Alan Phipps wrote:I think this is probably generic code for use with any window-enabled X-game so far and so is probably best left here for now.

I also think that if this leaves the game vanilla (which it obviously does) and has no untoward effects (to be tested by users) then it would merit being offered as a linked entry in the appropriate Resources and Guides Sticky listing.

I guess I've played too many other games, especially MMO's, cause when I saw this, my eyes said :o

The thought of 3rd party programs being allowed to alter game functions (regardless of in game or not) is just.....well..... this says it all: :o

I would have expected this at minimum in tech support, if not s/m :)



But then, I'm a 5th of Bacardi in, so I'm not gonna question it. :lol:
All your Hyperion Vanguards are belong to us.
Alan Phipps
Moderator (English)
Moderator (English)
Posts: 31630
Joined: Fri, 16. Apr 04, 19:21
x4

Post by Alan Phipps »

@ Lazerius: It is not altering a game function. It is altering the size/position of a display of a window by the OS and which happens to resolve a display issue seen by some when playing any X game in a window. Yes it could go in Tech Sp/S&M (where few vanilla players would see it) but it would have to be spread over Tech Sp or S&M forums for all X games and there would be no consistency in comments, tweaks or bug-reports as a result.

It is no more a game mod than say mrbadger's savegame manager written in Java and so needing Java to be installed.
A dog has a master; a cat has domestic staff.
Coreblimey
Posts: 1170
Joined: Wed, 25. Aug 10, 17:48
x3tc

Post by Coreblimey »

Alan Phipps wrote:Yes it could go in Tech Sp/S&M (where few vanilla players would see it) but it would have to be spread over Tech Sp or S&M forums for all X games and there would be no consistency in comments, tweaks or bug-reports as a result.
I never thought of that. That's probably why you're a Moderator and I'm not. :)
If it doesn't work, give it a kick. If that doesn't fix it hit it with a hammer. If it still doesn't work, USE A BIGGER HAMMER!!!

Unknown Sector..... That's what you get for using Bing instead of Google!
slomer
Posts: 13
Joined: Mon, 13. Aug 12, 02:05

Post by slomer »

Da_Junka wrote:Nice one. Thanks guys. :)
I am glad it is helpful and that people were nice enough to answer your question. Autohotkey is a great tool, especially as a gamer as it can often be user to overcome shortcomings. I used it to add autorun and always on tab info for DAO:2 for example.
Solomon Short
Posts: 797
Joined: Wed, 25. Mar 09, 07:00
x4

Post by Solomon Short »

I'm thinking if/when I go back to TC I'll need to find out how to put multiple discrete hotkeys/scripts in one file so I can automate the various stages of equipping & assigning my various fleets of Mobile Miners (& a few other things, I'll need multiple functions in one file 'cos I really don't see a need for 20-30 extra & identical icons on the notification area).

Return to “X Trilogy Universe”