[Guide] : fake-fullscreen and optimisation



Not that well it seems)
Thanks for you comment I reread post and found one significant error:
It seem I Copy-pasted not the latest version, multipleer script neend one extra line to make it pause the loop
" Process, WaitClose, %procName%" in the end of "if" section. Without this line script do not pause the loop...


One more error fix: in "NewPID" remain procces ID of FAF Client, not the game, so process affinity was set for FAF Client, not for game 😕
Fixed by adding "NewPID := ErrorLevel" after setting high priority:

; set High priority and cores affinity 
        Process, Priority, %procName%, H
        NewPID := ErrorLevel
        ProcessHandle := DllCall("OpenProcess", "UInt", 0x1F0FFF, "Int", false, "UInt", NewPID)
        DllCall("SetProcessAffinityMask", "UInt", ProcessHandle, "UInt", 14 ) ; 1110x2 = 14x10 CPU 0 unchecked, CPU 1-3 checked
        DllCall("CloseHandle", "UInt", ProcessHandle)
        Process, WaitClose, %procName%

Hope it was last one...


whenever I'm back on windows I'll give it a spin and I'll let you know!


@io_nox Thanks for the script revision (also thanks to @tatsu for the original). I do have a couple questions.

  1. How would I revise the line for changing the affinity for 16 logical processors?

  2. To use this for the LOUD mod which uses the exe from the base SCFA install (Steam for me) but points to its own init file for loading, would I just need to replace "steam://rungameid/9420" in the script with the contents of the Target of the LOUD desktop shortcut ("F:\SteamLibrary\steamapps\common\Supreme Commander Forged Alliance\bin\SupremeCommander.exe" /log "..\logs\Loud.log" /init "..\LOUD\bin\LoudDataPath.lua")?

Any help you can provide is appreciated.




  1. well I type 1s and I count to 15 with every 1 and then I type a 0 :


do you mean with the IO_Nox method? no idea. maybe it does it automatically with his code?

  1. Again I don't know what script you're talking about. if it's mine then you just need to detect whatever exe so the name would be "SupremeCommander.exe"

affinity for 16 logical processors

as @tatsu said 15 ones and last zero may work, by on my 4 threads in win 10 number 1110 have not worked and 14 worked well. So you can try 1111111111111110 and if it is not working here some counting systems math staf:

  • for me 4 threads, so - 1110 in binary is 0 * 2^0 + 1 * 2^1 + 1 * 2^2 + 1 * 2^3 = 0 * 1 + 1 * 2 + 1 * 4 + 1 * 8 = 14 in decimal (normaly used in live)
  • for your 16 threads: 1111111111111110 binary is 65534 in decimal (from some random converter in goole search first page) 3a022b3d-6273-410f-b842-9eb21f045a27-image.png
    so you will have:
DllCall("SetProcessAffinityMask", "UInt", ProcessHandle, "UInt", 65534 )

It works like you are setting yes/no flags for each CPU: 0 to disable and 1 to anable, and combines result in 1 number. Flag f for CPU-N will be f * 2^N and sum of all flags is your number. Why fist CPU-0 is always last right? It's because in numbers power order is reverted - similar way 65534 in decimal is 4 * 10^0 + 3 * 10^1 + 5 * 10^2 + 5 * 10^3 + 6 * 10^4

replace "steam://rungameid/9420" in the script with the contents of the Target of the LOUD desktop shortcut ("F:\SteamLibrary\steamapps\common\Supreme Commander Forged Alliance\bin\SupremeCommander.exe" /log "..\logs\Loud.log" /init "..\LOUD\bin\LoudDataPath.lua")?

Should work I think, thecnicaly it is just link or path to executable file. Where is no tricky symbols in path ""F:\SteamLibrary\steamapps\common\Supreme Commander Forged Alliance\bin\SupremeCommander.exe"
but I don't know if " /log "..\logs\Loud.log" /init "..\LOUD\bin\LoudDataPath.lua"" additional part will work properly but usually it should work.

Based on this https://www.autohotkey.com/docs/commands/Run.htm#Remarks
and this

Try somethig like

Run, "F:\SteamLibrary\steamapps\common\Supreme Commander Forged Alliance\bin\SupremeCommander.exe" /log "..\logs\Loud.log" /init "..\LOUD\bin\LoudDataPath.lua"


Run, "F:\SteamLibrary\steamapps\common\Supreme Commander Forged Alliance\bin\SupremeCommander.exe" log "..\logs\Loud.log"  init "..\LOUD\bin\LoudDataPath.lua"


Run %ComSpec% /c ""F:\SteamLibrary\steamapps\common\Supreme Commander Forged Alliance\bin\SupremeCommander.exe" /log "..\logs\Loud.log" /init "..\LOUD\bin\LoudDataPath.lua""

or anover variation.


faster way to get magical number for N threads is
2^N - 2

  • 2 threads: 4 - 2 = 2
  • 4 threads: 16 - 2 = 14
  • 6 threads: 64 - 2 = 62
  • 8 threads: 256 - 2 = 254
  • 10 threads: 1024 - 2 = 1022
  • 12 threads: 4096 - 2 = 4094
  • 14 threads: 16384 - 2 = 16382
  • 16 threads: 65536 - 2 = 65534
    why: 2^N - 1 in binary will be number of N ones (111...111) we need number lower by 1, so (2^N - 1) - 1 is 11...110


path := "C:\Program Files\Notepad++\notepad++.exe --help"
Run, %path%

worked well so may be your mod will run same way.

may be I will soon update script one more time to use 1 script for both singleplayer and faf....


New script revision

I tried to localize all variable you need to set manually in the begining.
Threads count is now AHK work!
This is 2 in 1 script.
(May be one day I will do 3 in 1 for any map editor... but now I think it will work if you change all FAF Client staff to your Map Editor staff)

My steam shortcut simply runs script


My faf client shortcut runs SAME script with command line parameter faf
Object value is:
"D:\Program Files\SC FAF borderleess.ahk" faf

![faf shortcut Properties img](a181882b-4a64-4edf-8849-966746c95b13-image.png image url)

One Script to run them all!

if I

  • run it with command line parameter faf (no matter file name) or
  • rename script file into FAF borderleess.ahk
    it will run FAF Client
  • else it will run game from steam (if file name NOT starts with "faf").

If file name starts from FAF it will allways run FAF, so you can have 2 copies like "faf script.ahk" and "sc script.ahk" to run game if you don't want to use command line parameter:

  • "faf script.ahk" will run only multiplayer, and
  • "sc script.ahk" will run singleplayer by default and multiplayer if called with parameter faf

"D:\Program Files\Downlord's FAF Client\downlords-faf-client.exe" is not starting client... but "downlords-faf-client.exe" works fine (if script is in faf client's dir)...
so i am calling this script from fake faf shortcut to call another faf client shortcut from it...
Interesting thing is that AHK tells me "File exists" if I'm giving it my full path... but can't run it...

About runnig game with command line args:
AHK can do it, but some trying, AHK docks reading and googlesearching may be needed. I left some tips in code as comments, maybe it will be helpfull.

File D:\Program Files\SC FAF borderleess.ahk:

SendMode Input
SetWorkingDir %A_ScriptDir%

; all personal variables are here

; move the window to 0,0 and resize it to fit across 1 or 2 monitors
moveX := 0
moveY := 0
width := 1920
height := 1080

; single player game link from steam or normal file path
pathOrLinkGame := "steam://rungameid/9420"

; multiplayer client path
pathOrLinkClient := "D:\Program Files\downlords-faf-client.lnk"

; problem:
; "D:\Program Files\Downlord's FAF Client\downlords-faf-client.exe"
; is not starting client... but "downlords-faf-client.exe" works...
; but then this script must be in faf client dir...
; so i am calling this script from shortcut to call faf shortcut from it...

; if you run game with command line parameters add them in path string,
; for example path := "C:\Program Files\Notepad++\notepad++.exe --help"
; works fine, note: in *.lnk Object string works like 
; "my.exe" myArg1
; but here it will be like path := "my.exe myArg1"
; Some tips from AHK docks:
; If path/link string contains any commas, they must be escaped 
; as shown three times in the following example:
; Run rundll32.exe shell32.dll`,Control_RunDLL desk.cpl`,`, 3  
; It opens Control Panel > Display Properties > Settings
; To include an actual quote character inside a quoted string,
; specify two consecutive quotes as shown twice in this example: 
; "She said, ""An apple a day.""".

; usually you don't need to cheange anythig else bellow
; you can uncomment DEBUG MESSAGE STRING bellow
; to check how script have autoset some variables

; process (*.exe) names for game and faf client
procSingleplayer := "SupremeCommander.exe"
procMultiplayer := "ForgedAlliance.exe" 
procClient := "downlords-faf-client.exe"

; this will automatically find your processor threads count
EnvGet, ProcessorCount, NUMBER_OF_PROCESSORS

singlePlayer := true
; true to run singleplayer game
; false to run multiplayer faf-client
; script will try to detect it automatically

; get command line first agrument
firstArg := A_Args[1]
StringLower, lowerCaseFirstArg, firstArg

; get first 3 lettest of this script file name
first3chars := SubStr(A_ScriptName, 1, 3)
StringLower, lowerCaseFirst3chars, first3chars

; it will set singlePlayer to false in 2 cases:
; case 1:
;	script runs with command line argument "faf" or "FAF"
;	for example Object field in *.lnk:
;	"D:\Program Files\SC FAF borderleess.ahk" faf
; case 2:
;	file name of this script starts with "FAF..." or "faf.."
;	for example: "D:\Program Files\FAF borderleess.ahk"

if(lowerCaseFirstArg = "faf" or lowerCaseFirst3chars = "faf")
	singlePlayer := false
; now "singlePlayer" variable is set

; process for game
procGame := singlePlayer ? procSingleplayer : procMultiplayer

; DEBUG MESSAGE STRING is bellow, this string is to check if it works right
; MsgBox, % ProcessorCount " threads " ( singlePlayer ? "Singleplayer: " : "Multiplayer: " ) procGame
; delete ; character to uncomment string above to see info window on script start

procName := singlePlayer ? procGame : procClient
procPath := singlePlayer ? pathOrLinkGame : pathOrLinkClient

; Start game or client and 
; wait for process to start, but no more then 120 seconds
Run, %procPath%
Process, Wait, %procName%, 120
procPID := ErrorLevel
if not procPID
    MsgBox The specified process did not appear.
    ExitApp ; Stop this script

SetTimer, CheckProc, 2000

	; Stop then FAF Client stoped
	Process, WaitClose, %procClient%

    if (!ProcessExist(procGame))

    WinGet Style, Style, % "ahk_exe " procGame
    if (Style & 0xC40000)
		; remove the titlebar and borders
        WinSet, Style, -0xC40000, % "ahk_exe " procGame 
		; move the window to 0,0 and resize it to fit across 1 or 2 monitors.
        WinMove, % "ahk_exe " procGame , , moveX, moveY, width, height
        WinMaximize, % "ahk_exe " procGame
        WinRestore, % "ahk_exe " procGame

        ; set High priority and cores affinity 
        Process, Priority, %procGame%, H
        gamePID := ErrorLevel
        ProcessHandle := DllCall("OpenProcess", "UInt", 0x1F0FFF, "Int", false, "UInt", gamePID)
        DllCall("SetProcessAffinityMask", "UInt", ProcessHandle, "UInt", 2**ProcessorCount - 2 )
		DllCall("CloseHandle", "UInt", ProcessHandle)
		; I have 4 threads, so 2**ProcessorCount - 2 will be 2^4 - 2= 16 - 2 = 14
		; 1110 binary = 14 decimal.
		; this means CPU 0 unchecked (right most 0 in binary number), 
		; CPU 1-3 checked (ones in binary number) for 4 threads optimization
			ExitApp  ; Stop this script
			Process, WaitClose, %procGame%

   Process, Exist, %exeName%
   return !!ERRORLEVEL

@tatsu Sorry for the confusion. I was indeed asking about IO's script.

@IO_Nox Thanks for the feedback. I used that info along with your revised 2-in-1 script & was able to setup a script for Steam/FAF & a script for using the LOUD mod with Steam. The only thing I need to do now is create a script for those cases that I want to launch the FAF exe offline (not through the client), but I should be able to mash something together by following all the provided info & examples.

Thanks again for your help!


@MostLostNoob by the way once you have everything working, post a full guide to your setup here

there might be a lot of other people who might want to do what you did and they will be very grateful to have something to follow.


To get the 2-in-1 script by @IO_Nox configured to work with the Loud mod & FAF, there are at least a couple ways to go:

  1. If you haven't already done so, go into the Tools of the SCFA_Updater.exe (aka LOUD Updater) & Create Shortcuts. You should see a couple new shortcuts, one of which is called LOUD Forged Alliance. In the script, change the reference for pathOrLinkGame to point to the new LOUD Forged Alliance shortcut. The shortcut already has the parameters it needs for running Loud in the target.

  2. If you don't want to use a shortcut reference, you can enter the parameters directly in the script:

pathOrLinkGame := "F:\SteamLibrary\steamapps\common\Supreme Commander Forged Alliance\bin\SupremeCommander.exe /log ""F:\SteamLibrary\steamapps\common\Supreme Commander Forged Alliance\LOUD\bin\Loud.log"" /init ""..\LOUD\bin\LoudDataPath.lua"""

The paths above are for my SCFA & Loud installs, so make sure you change them as needed for yours. Also note that for the log parameter, the full path is need instead of just using ..\LOUD like for the init parameter.

The code for the FAF side of things remains unchanged.

With the changes complete, to play Loud, just open the script file normally. To play FAF, either open the Run command (Windows+R) & enter the script's file path followed by an faf parameter or copy/paste the script file & rename it beginning with FAF.


By the way, AHK can make some GUI
....so if someone need to run everything from 1 script and/or 1 shortcut it is possible to make interactive window whith buttons or other standard controlles and then run things by "double-click sortcut->see a small dialog window -> press one of buttons or somethig similar -> game started in some way"


@tatsu said in [Guide] : fake-fullscreen and optimisation:


Where do you download AutoHotkey? and does FAF still allow it?


Ok i found where to get AutoHotkey, I am using AutoHotkey_2.0-beta
I am finding the script gets errors (#NoEnv error this line does not contain a recognized action)
Should i be using current version of AutoHotkey instead of beta?


Ok #NoEnv has been removed, going through and seeing if i can update the script for AutoHotkey 2


Ok Using now AutoHotkey 1.1 version (which seems to have fixed the errors)

ui party is missing dependencies, not sure how to fix this


@thecore you need to install and enable common mod tools.

Please consider using edits instead of posting multiple times.


@deletethis Yeah i had a forum bug where i did not have permission to make an edit

Anyway got it all working


I have improved the script, here is my result

The Definitive Supreme Commander Windowed Script

For single and dual screen
thecore, tatsu, IO_Nox other sources on the net

Supports the following
Forged Alliance Forever
Downlord's FAF Client
LOUD Forged Alliance
Steam Forged Alliance
Steam Supreme Commander
Switch between single and dual screen
Lock mouse within game

How to install

  1. Install all the different version of Supreme Commander (see Features of supported games)

  2. Install Common Mod Tools mod (This can be done from the Downlord's FAF Client)

  3. Install ui-party mod (This can be done from the Downlord's FAF Client)
    Now open each game, enable ui-party mod and set resolution to Windowed, DO NOT SKIP THIS
    NOTE Steam Supreme Commander does not support ui-party mod

  4. Download Supreme Commander Launchers.zip
    Now i am not able to upload a zip file for some strange reason so i have embedded it into a doc file, open the doc file and upzip from there
    Supreme Commander Launchers.doc
    If a forum moderator can fix the zip upload they can update it here

  5. Unzip Supreme Commander Launchers to your game directory
    Note you should have 5 shortcuts (that will be configured) a scripts folder and an icons folder

  6. Configure Client Forged Alliance Forever shortcut
    right click on Client Forged Alliance Forever shortcut and select properties
    Enter in the following for target, note you must enter in you drive letter and the directory locaiton
    "D:\THE LOCATION TO THE GAME DIRECTORY\Supreme Commander Launchers\scripts\AutoHotkeyU32.exe" "D:\THE LOCATION TO THE GAME DIRECTORY\Supreme Commander Launchers\scripts\multiMonitor.ahk" client

NOTE the " client is the pram


Click change icon and use the icon in the icons folder (forgedallianceIcon.ico)
Repeat the process for the other shortcuts, however replace pram in Target as follows
Client Forged Alliance Forever = multiMonitor.ahk" client
Forged Alliance Forever = multiMonitor.ahk" faf
LOUD Forged Alliance = multiMonitor.ahk" loud
Steam Forged Alliance = multiMonitor.ahk" steamFAF
Steam Supreme Commander multiMonitor.ahk" steamSC

An example of what the shortcuts will look like are

Client Forged Alliance Forever
"E:\Games\Supreme Commander Launchers\scripts\AutoHotkeyU32.exe" "E:\Games\Supreme Commander Launchers\scripts\multiMonitor.ahk" client

Start in
"E:\Games\Supreme Commander Launchers"

Forged Alliance Forever
"E:\Games\Supreme Commander Launchers\scripts\AutoHotkeyU32.exe" "E:\Games\Supreme Commander Launchers\scripts\multiMonitor.ahk" faf

Start in
"E:\Games\Supreme Commander Launchers"

LOUD Forged Alliance
"E:\Games\Supreme Commander Launchers\scripts\AutoHotkeyU32.exe" "E:\Games\Supreme Commander Launchers\scripts\multiMonitor.ahk" loud

Start in
"E:\Games\Supreme Commander Launchers"

Steam Forged Alliance
"E:\Games\Supreme Commander Launchers\scripts\AutoHotkeyU32.exe" "E:\Games\Supreme Commander Launchers\scripts\multiMonitor.ahk" steamFAF

Start in
"E:\Games\Supreme Commander Launchers"

Steam Supreme Commander
"E:\Games\Supreme Commander Launchers\scripts\AutoHotkeyU32.exe" "E:\Games\Supreme Commander Launchers\scripts\multiMonitor.ahk" steamSC
Start in
"E:\Games\Supreme Commander Launchers"

!! Dubble check to make sure everything is correct !!

So now you should have 5 shortcuts with icons each with a different pram

  1. open scripts\multiMonitor.ahk
    Note you can use notepad++

  2. Settings that the user can change if they want to
    "global clipMouse = true" on by default
    "global autoSetMonitorSize := true" on by default
    "global startInDualScreenMode := false" off by default

  3. Settings the user must change !!!
    The directory of where the game exe is,
    e.g "E:\Games\supremeCommanderForgedAlliance"

By default FAF is located in "C:\ProgramData\FAForever\bin"
For LOUD you are need to find the SCFA_Updater.exe location
For Downlord's FAF Client you need to find the downlords-faf-client.exe location

That should be it for setting up

How to use
To enable dual Screen mode press Ctrl F12
To enable single Screen mode press Ctrl F11
To stop the script press Ctrl F10
You can use the windows key to untrap the mouse

Bugs and limitations
ui-party mod
If you switch from dual screen to single screen when the match has started the idle avatar does not position correctly.
The ui-party icon also does not position correctly.
The drop down menu also does not quite position correctly
Steam Supreme Commander does not support ui-party mod


I spent a few days to get this to work I hope people find it helpful.