• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Login
FAForever Forums
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Login

[Guide] : fake-fullscreen and optimisation

Scheduled Pinned Locked Moved Frequently Asked Questions
91 Posts 18 Posters 32.0k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I
    IO_Nox
    last edited by 28 Aug 2021, 19:05

    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

    [{000214A0-0000-0000-C000-000000000046}]
    Prop3=19,9
    [InternetShortcut]
    IDList=
    IconIndex=0
    URL=file:///D:/Program%20Files/SC%20FAF%20borderleess.ahk
    IconFile=D:\Steam\steam\games\540979be595a41206b56a2e427c29dce1c212ad2.ico
    HotKey=0
    

    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").

    Note:
    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

    Problem:
    "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:

    #NoEnv
    SendMode Input
    SetWorkingDir %A_ScriptDir%
    #Persistent
    
    
    ; 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
    
    if(!singlePlayer)
    {
    	; Stop then FAF Client stoped
    	Process, WaitClose, %procClient%
    	ExitApp
    }
    
    
    CheckProc:
        if (!ProcessExist(procGame))
            return
    
        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
            
            if(singlePlayer)
    		{
    			ExitApp  ; Stop this script
    		}
    		else
    		{
    			Process, WaitClose, %procGame%
    		}
        }
    return
    
    ProcessExist(exeName)
    {
       Process, Exist, %exeName%
       return !!ERRORLEVEL
    }
    return
    
    1 Reply Last reply Reply Quote 2
    • MostLostNoobM
      MostLostNoob
      last edited by 29 Aug 2021, 22:31

      @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!

      1 Reply Last reply Reply Quote 0
      • tatsuT
        tatsu
        last edited by 30 Aug 2021, 13:10

        @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.

        How to setup FAF on linux

        1 Reply Last reply Reply Quote 0
        • MostLostNoobM
          MostLostNoob
          last edited by 31 Aug 2021, 15:12

          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.

          1 Reply Last reply Reply Quote 1
          • IO_NoxI
            IO_Nox
            last edited by 31 Aug 2021, 16:24

            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"

            1 Reply Last reply Reply Quote 1
            • T
              thecore @tatsu
              last edited by 11 Sept 2021, 00:48

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

              AutoHotkey

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

              Never Fear, A Geek is Here!

              1 Reply Last reply Reply Quote 0
              • T
                thecore
                last edited by 11 Sept 2021, 02:47

                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?

                Never Fear, A Geek is Here!

                1 Reply Last reply Reply Quote 0
                • T
                  thecore
                  last edited by 11 Sept 2021, 03:01

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

                  Never Fear, A Geek is Here!

                  1 Reply Last reply Reply Quote 0
                  • T
                    thecore
                    last edited by 11 Sept 2021, 03:57

                    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

                    Never Fear, A Geek is Here!

                    1 Reply Last reply Reply Quote 0
                    • deletethisD
                      deletethis
                      last edited by 11 Sept 2021, 06:11

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

                      Please consider using edits instead of posting multiple times.

                      T 1 Reply Last reply 11 Sept 2021, 08:24 Reply Quote 0
                      • T
                        thecore @deletethis
                        last edited by 11 Sept 2021, 08:24

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

                        Anyway got it all working

                        Never Fear, A Geek is Here!

                        1 Reply Last reply Reply Quote 0
                        • T
                          thecore
                          last edited by 14 Sept 2021, 07:39

                          I have improved the script, here is my result

                          The Definitive Supreme Commander Windowed Script

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

                          Features
                          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
                            !REPLACE ALL CAPS!
                            "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

                          Replace Start In with the THE LOCATION TO THE SUPREME COMANDER LAUNCHERS FOLDER

                          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
                          Target
                          "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
                          Target
                          "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
                          Target
                          "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
                          Target
                          "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
                          Target
                          "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 !!!
                            pathOrLinkLOUD
                            pathOrLinkClient
                            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

                          Untitled-1.jpg

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

                          Never Fear, A Geek is Here!

                          1 Reply Last reply Reply Quote 4
                          • M
                            macdeffy
                            last edited by 15 Sept 2021, 00:33

                            for those who aren't aware, there is a program to convert ahk scripts to an exe that you can simply run at startup, or create a task schedule to run on specific triggers.

                            https://github.com/AutoHotkey/Ahk2Exe

                            1 Reply Last reply Reply Quote 0
                            • T
                              thecore
                              last edited by 15 Sept 2021, 00:58

                              For my updated script you do not need to convert the ahk file.
                              Just right click on the ahk file and go properties and click open with and select the AutoHotkeyU32.exe file in scripts

                              Never Fear, A Geek is Here!

                              1 Reply Last reply Reply Quote 0
                              • T
                                thecore
                                last edited by 16 Sept 2021, 03:41

                                Another improvement I just made is auto detect when the match is loading and auto switch to dual screen mode. This using the ImageSearch function.

                                To do this you do

                                SetTimer, loadingSearch, 100
                                
                                loadingSearch:
                                	if (!ProcessExist(procGame)) 
                                		return
                                	;//checks if t
                                	if(!loaded) 
                                		return
                                	var := 0
                                	loop , 8
                                	{
                                	  var += 1
                                	  CoordMode Pixel,Relative
                                	  ImageSearch, FoundX, FoundY, 0, 0, width, height, *50, %A_ScriptDir%\pics\%var%.jpg ;
                                	  if (ErrorLevel = 0)
                                	  {
                                		resize(width*2, height,procGame,true)
                                		settimer, loadingSearch, OFF
                                		break
                                	  }
                                	 }
                                return
                                

                                And the references pics you can use are here, put them in a folder in scripts called pics and call them
                                1.jpg
                                2.jpg
                                3.jpg
                                4.jpg
                                5.jpg
                                6.jpg
                                7jpg
                                8.jpg
                                1.jpg
                                2.jpg
                                3.jpg
                                4.jpg
                                5.jpg
                                6.jpg
                                7.jpg
                                8.jpg

                                Now i have only tested for 1920x1080 so if the ImageSearch cannot find the image you may need to play around with it.

                                I updated the resize rule

                                resize(x, y, gametype,active) 
                                {
                                	if(active = true)
                                	{
                                		if(dualScreenActive = true)
                                			return
                                		dualScreenActive := true
                                	}
                                	else
                                	{
                                		if(dualScreenActive = false)
                                			return
                                		dualScreenActive := false
                                	}	
                                		WinMove, % "ahk_exe " gametype , , moveX, moveY, %x%, %y% 
                                		WinMaximize, % "ahk_exe " gametype
                                		WinRestore, % "ahk_exe " gametype
                                }
                                

                                The full script

                                ;//The Definitive Supreme Commander Windowed Borderless Script
                                ;//thecore, tatsu, IO_Nox other sources on the net
                                ;//1.01
                                
                                ;//Supports 
                                ;//dual Monitors of the same resolution
                                ;//mouse cursor traping
                                ;//Supreme Commander steam version
                                ;//Supreme Commander Forged Alliance steam version
                                ;//Forged Alliance Forever 
                                ;//Downlord's FAF Client
                                ;//LOUD
                                
                                ;//limitations
                                ;//Only supports monitors of the same resolution
                                ;//ui-party does not support steam Supreme Commander (9350)
                                
                                #NoEnv
                                SendMode Input
                                SetWorkingDir %A_ScriptDir%
                                #Persistent
                                
                                ;//all personal variables are here
                                global moveX := 0 ;//Sets the main screen x location, 0 being the "main display" X location
                                global moveY := 0 ;//Sets the main screen x location, 0 being the "main display" Y location
                                global width := 0 ;//resolution width (do not change)
                                global height := 0 ;//resolution height (do not change)
                                global clipMouse = true ;//This will trap the mouse cursor within the game while the game window is active, you can use windows key to deactivate the game window,
                                global autoSetMonitorSize := true ;//set to use auto set resolution 
                                if(autoSetMonitorSize == true)
                                {
                                	SysGet, Mon1, Monitor, 1 ;//get monitor 1 resolution
                                	width := % Mon1Left ; //set width resolution
                                	height := % Mon1Bottom ; //set width resolution
                                	;//if the value is negative change it to positive number
                                	if(width < 0)
                                	{
                                		width := (-1 * width)
                                	}
                                	if(height < 0)
                                	{
                                		height := (-1 * height)
                                	}
                                }
                                else
                                { ;//manually set monitor resolution size
                                	width := 1920  ;2560, 3840 ;//Sets the width resolution, for 1080p use (1920), for 1440p use (2560), for 4k use (3840) or use a custom value
                                	height := 1080 ;1440, 2160 ;//Sets the height resolution
                                }
                                
                                global startInDualScreenMode := false ;//Set the default Screen mode on startup, true is start in dual screen mode
                                global dualScreenActive := startInDualScreenMode ;//(do not change)
                                ;//hotkey for dual screen mode is Ctrl F12
                                ;//hotkey for single screen mode is Ctrl F11
                                ;//hotkey for exit script is Ctrl F10
                                
                                ;//Paths to different game exe types
                                global pathOrLinkSteamSC := "steam://rungameid/9350" ;//Location to Supreme Commander steam version
                                global pathOrLinkSteamFaf := "steam://rungameid/9420" ;//Location to Supreme Commander Forged Alliance steam version
                                
                                global pathOrLinkFAF := "C:\ProgramData\FAForever\bin" ;//Location to Forged Alliance Forever exe (this is normally found in "C:\ProgramData\FAForever\bin")
                                global pathOrLinkLOUD := "E:\Games\supremeCommanderForgedAlliancee" ;//Location to LOUD SCFA_Updater.exe
                                global pathOrLinkClient := "E:\Games\Downlord's FAF Client" ;//Location to Downlord's FAF Client exe
                                
                                ;//the name of the exe for each game type
                                global procSteamSC := "SupremeCommander.exe" ;//Supreme Commander steam version
                                global procSteamFaf := "SupremeCommander.exe" ;//Supreme Commander Forged Alliance steam version
                                global procFAF := "ForgedAlliance.exe" ;//Forged Alliance Forever 
                                global procClient := "downlords-faf-client.exe" ;//Downlord's FAF Client
                                global procLOUD := "SCFA_Updater.exe" ;//LOUD Updater
                                
                                ;//Set the number of processor threads to use, by default it will find auto find the max supported processors
                                EnvGet, ProcessorCount, NUMBER_OF_PROCESSORS
                                
                                firstArg := A_Args[1] ;//get shortcut parameters command line first agrument
                                StringLower, lowerCaseFirstArg, firstArg ;//Sets firstArg to lower case, not really needed but just in case the user puts in a uppercase value
                                global procGame := "null" ;//holds the game exe to use 
                                
                                global loaded := false
                                
                                ;//Run the following exe based off pram from shortcut
                                ;//procGame - Sets which game exe name to use, this is the exe that will have the width and height changed
                                ;//procName - Sets which exe that needs to be closed to stop the ahk script (e.g for the Downlord's FAF Client the script will stop once the client is shutdown and not the game exe)
                                ;//procPath - Sets the game path
                                ;//Run, %procName%, %procPath% - run the exe at the path
                                if(lowerCaseFirstArg = "client")
                                { ;//Run the Downlord's FAF Client
                                	procGame := procFAF
                                	procName := procClient
                                	procPath := pathOrLinkClient
                                	Run, %procName%, %procPath%
                                }
                                else if(lowerCaseFirstArg = "faf" )
                                { ;//Run Forged Alliance Forever
                                	procGame := procFAF
                                	procName := procFAF
                                	procPath := pathOrLinkFAF
                                	Run, %procName%, %procPath%
                                }
                                else if(lowerCaseFirstArg = "steamFAF")
                                { ;//Run upreme Commander Forged Alliance steam version
                                	procGame := procSteamFaf
                                	procName := procSteamFaf
                                	procPath := pathOrLinkSteamFaf
                                	Run, %procPath%
                                }
                                else if(lowerCaseFirstArg = "loud")
                                { ;//Run LOUD 
                                	procGame := procFAF
                                	procName := procLOUD
                                	procPath := pathOrLinkLOUD
                                	Run, %procName%, %procPath%
                                }
                                else if(lowerCaseFirstArg = "steamSC")
                                { ;//Run LOUD 
                                	procGame := procSteamSC
                                	procName := procSteamSC
                                	procPath := pathOrLinkSteamSC
                                	Run, %procPath%
                                }
                                
                                Process, Wait, %procName%, 120 ;//Wait upto 120 seconds for the exe to start
                                procPID := ErrorLevel ;//set the error level
                                
                                ;//if the exe does not start show an error message and exit the script
                                if not procPID
                                { 
                                	MsgBox The specified process did not appear.
                                    ExitApp ; Stop this script
                                }
                                
                                ;//Call the exitProc function after the set time
                                SetTimer, exitProc, 2000 
                                ;//Call the CheckProc function after the set time
                                SetTimer, CheckProc, 2000
                                if(clipMouse == true)
                                {
                                	SetTimer, clipProc, 100 
                                }
                                
                                SetTimer, loadingSearch, 100
                                
                                ;//Function that will Manually switch from dual screen to single screen
                                resize(x, y, gametype,active) 
                                {
                                	if(active = true)
                                	{
                                		if(dualScreenActive = true)
                                			return
                                		dualScreenActive := true
                                	}
                                	else
                                	{
                                		if(dualScreenActive = false)
                                			return
                                		dualScreenActive := false
                                	}	
                                		WinMove, % "ahk_exe " gametype , , moveX, moveY, %x%, %y% 
                                		WinMaximize, % "ahk_exe " gametype
                                		WinRestore, % "ahk_exe " gametype
                                }
                                
                                ;//Hot key to switch from dual screen to single screen or to exit the script
                                ^F12::resize(width*2, height,procGame,true) ;//Ctrl F12 to enter dual screen mode
                                ^F11::resize(width, height,procGame,false) ;//Ctrl F11 to enter single screen mode
                                ^F10::quit() ;//Ctrl F10 to stop the script
                                
                                ;//Resize the game on start up,
                                CheckProc:
                                	if (!ProcessExist(procName)) 
                                		return
                                	WinGet Style, Style, % "ahk_exe " procGame ;//Gets the style from the game exe
                                	
                                	if (Style & 0xC40000)
                                	{ 
                                        WinSet, Style, -0xC40000, % "ahk_exe " procGame ;//removes the titlebar and borders
                                		
                                		windowWidth := width ;//sets the windowWidth value to width
                                		;//Checks the default screen mode
                                		if(startInDualScreenMode = true) 
                                		{ 
                                			windowWidth := windowWidth*2 ;//use dual screen mode as default
                                		}
                                		
                                		; //move the window to 0,0 and resize it to fit across 1 or 2 monitors.
                                		WinMove, % "ahk_exe " procGame , , moveX, moveY, windowWidth, height
                                        WinMaximize, % "ahk_exe " procGame
                                        WinRestore, % "ahk_exe " procGame
                                
                                        ; //set High priority
                                        Process, Priority, %procGame%, H
                                        
                                		; //sets the number of processors to use, by default it will use all processor except CPU0
                                		; //NOTE with windows 10, windows 11 this is not really needed 
                                		gamePID := ErrorLevel
                                        ProcessHandle := DllCall("OpenProcess", "UInt", 0x1F0FFF, "Int", false, "UInt", gamePID)
                                        DllCall("SetProcessAffinityMask", "UInt", ProcessHandle, "UInt", 2**ProcessorCount - 2 )
                                		DllCall("CloseHandle", "UInt", ProcessHandle)
                                		loaded := true
                                    }
                                return
                                
                                clipProc: 
                                	if (!ProcessExist(procGame)) 
                                		return
                                	;//checks if the game window is active
                                	if !WinActive("ahk_exe " procGame)
                                	{
                                		return
                                	}	
                                	;//trap mouse
                                	Confine := !Confine
                                	setWidth := width
                                	;//trap mouse to dual screen
                                	if(dualScreenActive == true)
                                	{
                                		setWidth := setWidth * 2
                                	}
                                	ClipCursor( Confine, 0, 0, setWidth, height)
                                	
                                return
                                
                                loadingSearch:
                                	if (!ProcessExist(procGame)) 
                                		return
                                	;//checks if t
                                	if(!loaded) 
                                		return
                                	var := 0
                                	loop , 8
                                	{
                                	  var += 1
                                	  CoordMode Pixel,Relative
                                	  ImageSearch, FoundX, FoundY, 0, 0, width, height, *50, %A_ScriptDir%\pics\%var%.jpg ;
                                	  if (ErrorLevel = 0)
                                	  {
                                		resize(width*2, height,procGame,true)
                                		settimer, loadingSearch, OFF
                                		break
                                	  }
                                	 }
                                return
                                
                                ClipCursor( Confine=True, x1=0 , y1=0, x2=1, y2=1 ) 
                                {
                                	VarSetCapacity(R,16,0),  NumPut(x1,&R+0),NumPut(y1,&R+4),NumPut(x2,&R+8),NumPut(y2,&R+12)
                                	return Confine ? DllCall( "ClipCursor", UInt,&R ) : DllCall( "ClipCursor" )
                                }
                                
                                ;//Check if the process exist
                                ProcessExist(exeName)
                                { 
                                   Process, Exist, %exeName%
                                   return !!ERRORLEVEL
                                }
                                
                                ;//exit script if the procName is not running
                                exitProc:
                                	if (ProcessExist(procName) == 0)
                                	{
                                		quit()
                                	}
                                return	
                                
                                ;//quit the script
                                quit()
                                { 	
                                	ExitApp
                                }
                                
                                return
                                

                                So now when a game starts it will try and find the image and switch to dual screen mode. Have tested it and it is working quite nicely though you may need to add more images for different mods.

                                Never Fear, A Geek is Here!

                                1 Reply Last reply Reply Quote 0
                                • T
                                  thecore
                                  last edited by 17 Sept 2021, 07:50

                                  Version 1.02

                                  • Added auto enable Dual screen mode (enableAutoDualScreen default is true)
                                  • Added auto disable Dual screen mode, the script will check for the end game stats
                                    menu
                                  • Improved some code and bugs

                                  Add the following images to \pics\endgame
                                  3.jpg 2.jpg 1.jpg

                                  and under \pics\loadgame
                                  8.jpg 7.jpg 6.jpg 5.jpg 4.jpg 3.jpg 2.jpg 1.jpg

                                  Here is version 1.02
                                  code.txt
                                  1.jpg
                                  2.jpg
                                  3.jpg
                                  4.jpg

                                  Bugs

                                  • The chart does not auto refresh when going from dual screen mode to single screen mode though you can just reselect the chart and it will refresh.
                                  • In order for auto dual screen to work you the game window has to be active.

                                  Never Fear, A Geek is Here!

                                  1 Reply Last reply Reply Quote 0
                                  • T
                                    thecore
                                    last edited by 19 Sept 2021, 22:59

                                    1.03
                                    Fix an issue with FAF client games where the loading Image timer was not turned back on resulting in the auto fullscreen not working after the first game.

                                    multiMonitor.txt

                                    Never Fear, A Geek is Here!

                                    1 Reply Last reply Reply Quote 0
                                    • T
                                      thecore
                                      last edited by 25 Sept 2021, 03:39

                                      1.04
                                      Fix an issue where when using the downlords-faf-client the auto dual screen was not working correctly when playing the second game.

                                      Rename multiMonitor.txt to multiMonitor.ahk
                                      multiMonitor.txt

                                      Never Fear, A Geek is Here!

                                      IO_NoxI 2 Replies Last reply 25 Sept 2021, 15:53 Reply Quote 0
                                      • IO_NoxI
                                        IO_Nox @thecore
                                        last edited by 25 Sept 2021, 15:53

                                        Universal Sortcut Parser
                                        Version 1.0
                                        Universal Sortcut Parser.rar

                                        • Launch multiple applications from one shortcut.
                                        • Call usp.ahk with launch parameters and it will run sortcuts and scripts for this parameters.

                                        I tryed to divide command line arguments parsing, app starting and scripts. That way scripst may be more clean and reusable and you can ran many independent scripts and files for each option.
                                        I haven't compiled it, so AutoHotkey shold be installed.
                                        So it now works like

                                        • you call this proxy with command line arguments,
                                        • proxy launches files, links, scripts with predefined commandline arguments.

                                        Easiest way to create new option myOpt (if you will call scripts without any args) is to create dirs myOpt in both scripts and shortcuts dirs (or only one of them if you don't care, division of scrips and other files is made for scripts reusage in different options) and place your shortcuts, files and scripts there. And then create shortcut for usp.ahk and add command line argument myOpt in Object value like "usp.ahk" myOpt

                                        I now have 3 normal sortcuts (.lnk) on desctop for (Object values bellow):

                                        • Downlord's FAF Client
                                        "D:\Program Files\Universal Sortcut Parser\usp.ahk" faf
                                        
                                        • Supreme Commander Forged Alliance
                                        "D:\Program Files\Universal Sortcut Parser\usp.ahk" sc
                                        
                                        • FAForever Map Editor
                                        "D:\Program Files\Universal Sortcut Parser\usp.ahk" maps
                                        

                                        Note:

                                        "D:\Program Files\Universal Sortcut Parser\usp.ahk" faf sc maps
                                        
                                        • this will call all 3 options at once 🙂

                                        Options may be written in file and/or inerpreted from file names: files (and all files in folders) named for option in shortcuts and scripts folders will be called.

                                        Example for options.txt:

                                        test script blank testArg1 arg2
                                        test run C:\Program Files\Notepad++\notepad++.exe --help
                                        
                                        faf file D:\Program Files\Downlord's FAF Client\downlords-faf-client.exe
                                        faf script borderlessOptimisation ForgedAlliance.exe downlords-faf-client.exe
                                        
                                        
                                        sc run steam://rungameid/9420
                                        sc script borderlessOptimisation SupremeCommander.exe -
                                        
                                        maps file D:\Program Files\fafmapeditor_alpha_v0704_WIP1\FAForeverMapEditor.exe
                                        maps script borderlessOptimisation ForgedAlliance.exe FAForeverMapEditor.exe
                                        

                                        About options in file:

                                        • file will test if file (or dir) exsists and call it (or all files in dir),
                                        • run will just call anything, USE IT to call files with command line arguments,
                                        • scripts will search for all matching files and folders in scripts folder and can run them with normal and "additional" command line arguments.

                                        Note:

                                        • base script name can't contain spaces because spaces are dividers in string parsing, but it does not mater for files in folders.

                                        For example I have adapted my old script and placed it in
                                        scripts/borderlessOptimisation 0 0 1920 1080 folder and I'm calling it for sc option by string

                                        sc script borderlessOptimisation SupremeCommander.exe -
                                        

                                        This means that in scripts folder will be called all files named like borderlessOptimisation.exe, borderlessOptimisation second file.ahk, etc. and all files in directories named like borderlessOptimisation and borderlessOptimisation more args.
                                        If I have borderlessOptimisation second file.ahk it will be called with 2 args SupremeCommander.exe - (game and client proccees names for my script, "-" as second arg is to make it run normally if more args are added later).
                                        I have SC FAF borderleess ARGS.ahk in folder named borderlessOptimisation 0 0 1920 1080 so it will be called with 4 more args (6 args total), same as

                                        sc run scripts/borderlessOptimisation 0 0 1920 1080/SC FAF borderleess ARGS.ahk SupremeCommander.exe - 0 0 1920 1080
                                        

                                        and same may be done by copy-pasting original Supreme Commander Forged Alliance.lnk shortcut to shortcuts dir and remnaming it into "sc borderlessOptimisation SupremeCommander.exe -.lnk" or just placing shortcut in folder named this way.

                                        Read README.txt for more understending about the naming and some other things.

                                        IO_NoxI 1 Reply Last reply 25 Sept 2021, 16:15 Reply Quote 0
                                        • IO_NoxI
                                          IO_Nox @IO_Nox
                                          last edited by 25 Sept 2021, 16:15

                                          Added compiled script (usp.exe) here, but if you want to run AHK scripts(*.ahk) AHK instalation is still needed.

                                          Universal Sortcut Parser.rar

                                          1 Reply Last reply Reply Quote 0
                                          • First post
                                            Last post