Skip to content

Commit

Permalink
v1.3.0
Browse files Browse the repository at this point in the history
- added option to automatically kill incompatible processes, if specified, before starting the game
- added option to automatically run the game at first launch, after settings launcher / configuration utility is closed - useful with certain configuration utilities that can't launch the game
- added preset blank _RunBefore & _RunAfter functions to make it easier to create custom builds for certain games
  • Loading branch information
alex47exe committed Aug 6, 2019
1 parent 5f22f82 commit e6ec85b
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 35 deletions.
2 changes: 1 addition & 1 deletion ProgramData.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ___ UniGame Launcher v1.2.0 © 2017-2019, SalFisher47
# ___ UniGame Launcher v1.3.0 © 2017-2019, SalFisher47


[launcher]
Expand Down
6 changes: 3 additions & 3 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
### UniGame Launcher
### UniGame Launcher v1.3.0

Universal launcher for games, to be placed in game folder. I would say it's best to rename it to something like *_Game Name.exe*, so that it's the first file you see there. It includes two versions:

Expand All @@ -11,9 +11,9 @@ Universal launcher for games, to be placed in game folder. I would say it's best

- runs as administrator only at first launch, if `run_admin = 1` in *ini* file
- can run game executable with arguments and / or compatibility settings

- can run game executable on the first cpu core, thanks to included [RunFirst.exe](https://www.activeplus.com/products/runfirst) - to be used only on some older games that don't run properly on multi-core cpus
- can run the game through a different executable (e.g. settings launcher) at first launch
- can run the game through a different executable (e.g. settings launcher) at first launch - if `run_next = 1` in *ini* file, will automatically run the game after the settings launcher / configuration utility is closed
- if specified, can automatically terminate incompatible background processes before starting the game
- if savegame folder is specified, creates a *_savegame.lnk* shortcut to it

------
Expand Down
80 changes: 70 additions & 10 deletions UniGame_Launcher_one.au3
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UPX_Parameters=-9 --strip-relocs=0 --compress-exports=0 --compress-icons=0
#AutoIt3Wrapper_Res_Description=UniGame Launcher
#AutoIt3Wrapper_Res_Fileversion=1.2.0.47
#AutoIt3Wrapper_Res_ProductVersion=1.2.0.47
#AutoIt3Wrapper_Res_Fileversion=1.3.0.47
#AutoIt3Wrapper_Res_ProductVersion=1.3.0.47
#AutoIt3Wrapper_Res_LegalCopyright=2017-2019, SalFisher47
#AutoIt3Wrapper_Res_SaveSource=n
#AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker
Expand All @@ -20,24 +20,26 @@
#pragma compile(InputBoxRes, true)
#pragma compile(CompanyName, 'SalFisher47')
#pragma compile(FileDescription, 'UniGame Launcher')
#pragma compile(FileVersion, 1.2.0.47)
#pragma compile(FileVersion, 1.3.0.47)
#pragma compile(InternalName, 'UniGame Launcher')
#pragma compile(LegalCopyright, '2017-2019, SalFisher47')
#pragma compile(OriginalFilename, UniGame_Launcher_one.exe)
#pragma compile(ProductName, 'UniGame Launcher')
#pragma compile(ProductVersion, 1.2.0.47)
#pragma compile(ProductVersion, 1.3.0.47)
#EndRegion ;**** Pragma Compile ****

; === UniGame_Launcher_one.au3 =====================================================================================================
; Title .........: UniGame Launcher
; Version .......: 1.1.0.47
; Version .......: 1.3.0.47
; AutoIt Version : 3.3.14.5
; Language ......: English
; Description ...: Universal Game Launcher one
; Author(s) .....: SalFisher47
; Last Modified .: January 19, 2019 - last compiled on January 19 2019
; Last Modified .: August 9, 2019 - last compiled on August 9 2019
; ==================================================================================================================================

#include <StringConstants.au3>

Global $Env_RoamingAppData = @AppDataDir, _
$Env_LocalAppData = @LocalAppDataDir, _
$Env_ProgramData = @AppDataCommonDir, _
Expand Down Expand Up @@ -66,6 +68,8 @@ $exe_path_only_alt = StringTrimRight($exe_path_full_alt, StringLen($exe_only_alt
$exe_cmd_alt = IniRead($Ini, "Exe", "exe_cmd_alt", "")
$exe_compat_alt = IniRead($Ini, "Exe", "exe_compat_alt", "")

$run_next = IniRead($Ini, "Exe", "run_next", 0)

$run_first = IniRead($Ini, "Exe", "run_first", 0)
If Not FileExists(@AppDataCommonDir & "\SalFisher47\RunFirst") Then DirCreate(@AppDataCommonDir & "\SalFisher47\RunFirst")
FileInstall("RunFirst\RunFirst.exe", @AppDataCommonDir & "\SalFisher47\RunFirst\RunFirst.exe", 0)
Expand Down Expand Up @@ -94,6 +98,22 @@ Switch $ini_Savegame_dir
$Savegame_dir = @ScriptDir & "\" & $ini_Savegame_subdir
EndSwitch

; kill incompatible processes before starting the game
$Ini_kill_process = IniRead($Ini, "Launcher", "end_process", "")
$Kill_process = ""
If $Ini_kill_process <> "" Then
$Kill_process = StringSplit($Ini_kill_process, ", ", $STR_ENTIRESPLIT)
For $i = 1 To $Kill_process[0]
If ProcessExists($Kill_process[$i]) Then
ProcessClose($Kill_process[$i])
Sleep(50)
EndIf
Next
EndIf

;$desktopRatio = Round(@DesktopWidth/@DesktopHeight, 2)

; check if running as administrator, then execute _RunMain, _RunBefore & _RunAfter functions
If IniRead(@AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", "launcher", "game_path", "") <> @ScriptDir Then
$first_launch = 1
IniWrite(@AppDataCommonDir & "\SalFisher47\UniGame Launcher\" & StringTrimRight(@ScriptName, 4) & ".ini", "launcher", "game_path", " " & @ScriptDir)
Expand Down Expand Up @@ -125,9 +145,25 @@ Else
EndIf
EndIf

$desktopRatio = Round(@DesktopWidth/@DesktopHeight, 2)
Func _RunBefore_FirstLaunch()
; add commands here to run before game exe at first launch

EndFunc

Func _RunAfter_FirstLaunch()
; add commands here to run after game exe at first launch

_RunMain()
EndFunc

Func _RunBefore_EveryLaunch()
; add commands here to run before game exe at every launch, except the first one

EndFunc

Func _RunAfter_EveryLaunch()
; add commands here to run after game exe at every launch, except the first one

EndFunc

Func _RunMain() ; main script
RegRead('HKCU\Software\Valve\Steam', 'SteamPath')
Expand All @@ -145,28 +181,52 @@ If $Savegame_dir <> "" Then
EndIf
If $first_launch == 1 Then
; add commands here to run before game exe at first launch
;_RunBefore_FirstLaunch()
If $run_first == 1 Then
If $exe_run_alt <> "" Then
ShellExecute(@AppDataCommonDir & "\SalFisher47\RunFirst\RunFirst.exe", '"' & $exe_path_full_alt & '"' & " " & $exe_cmd_alt & " " & $CmdLineRaw, $exe_path_only_alt, "", @SW_HIDE)
If $run_next <> 1 Then
ShellExecute(@AppDataCommonDir & "\SalFisher47\RunFirst\RunFirst.exe", '"' & $exe_path_full_alt & '"' & " " & $exe_cmd_alt & " " & $CmdLineRaw, $exe_path_only_alt, "", @SW_HIDE)
Else
ShellExecute(@AppDataCommonDir & "\SalFisher47\RunFirst\RunFirst.exe", '"' & $exe_path_full_alt & '"' & " " & $exe_cmd_alt & " " & $CmdLineRaw, $exe_path_only_alt, "", @SW_HIDE)
ProcessWait($exe_only_alt)
ProcessWaitClose($exe_only_alt)
Sleep(250)
If Not ProcessExists($exe_only) Then
ShellExecute(@AppDataCommonDir & "\SalFisher47\RunFirst\RunFirst.exe", '"' & $exe_path_full & '"' & " " & $exe_cmd & " " & $CmdLineRaw, $exe_path_only, "", @SW_HIDE)
EndIf
EndIf
Else
ShellExecute(@AppDataCommonDir & "\SalFisher47\RunFirst\RunFirst.exe", '"' & $exe_path_full & '"' & " " & $exe_cmd & " " & $CmdLineRaw, $exe_path_only, "", @SW_HIDE)
EndIf
Else
If $exe_run_alt <> "" Then
ShellExecute($exe_only_alt, " " & $exe_cmd_alt & " " & $CmdLineRaw, $exe_path_only_alt)
If $run_next <> 1 Then
ShellExecute($exe_only_alt, " " & $exe_cmd_alt & " " & $CmdLineRaw, $exe_path_only_alt)
Else
ShellExecute($exe_only_alt, " " & $exe_cmd_alt & " " & $CmdLineRaw, $exe_path_only_alt)
ProcessWait($exe_only_alt)
ProcessWaitClose($exe_only_alt)
Sleep(250)
If Not ProcessExists($exe_only) Then
ShellExecute($exe_only, " " & $exe_cmd & " " & $CmdLineRaw, $exe_path_only)
EndIf
EndIf
Else
ShellExecute($exe_only, " " & $exe_cmd & " " & $CmdLineRaw, $exe_path_only)
EndIf
EndIf
; add commands here to run after game exe at first launch
;_RunAfter_FirstLaunch()
Else
; add commands here to run before game exe at every launch, except the first one
;_RunBefore_EveryLaunch()
If $run_first == 1 Then
ShellExecute(@AppDataCommonDir & "\SalFisher47\RunFirst\RunFirst.exe", '"' & $exe_path_full & '"' & " " & $exe_cmd & " " & $CmdLineRaw, $exe_path_only, "", @SW_HIDE)
Else
ShellExecute($exe_only, " " & $exe_cmd & " " & $CmdLineRaw, $exe_path_only)
EndIf
; add commands here to run after game exe at every launch, except the first one
;_RunAfter_EveryLaunch()
EndIf
EndFunc

Expand Down
Binary file modified UniGame_Launcher_one.exe
Binary file not shown.
14 changes: 11 additions & 3 deletions UniGame_Launcher_one.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# ___ UniGame Launcher v1.2.0 © 2017-2019, SalFisher47
# ___ UniGame Launcher v1.3.0 © 2017-2019, SalFisher47


[exe]
Expand All @@ -7,16 +7,20 @@
# For optional compatibility settings, use WIN95 / WIN98 / WINXPSP2 / WINXPSP3 / ...
# ... VISTARTM / VISTASP1 / VISTASP2 / WIN7RTM / WIN8RTM with or without RUNASADMIN
exe_run = game.exe
exe_cmd =
exe_cmd =
exe_compat =

# ___ Executable to run only at first launch, command-line parameters & compatibility settings
# Use it only if you need to run the game through a different executable (e.g. settings launcher) at first launch, ...
# ... or same as above, but with different command-line parameters & compatibility settings
exe_run_alt =
exe_cmd_alt =
exe_cmd_alt =
exe_compat_alt =

# ___ If 1, automatically runs 'exe_run' after 'exe_run_alt' is closed
# To be used with certain configuration utilities that can't launch the game
run_next = 0

# ___ If 1, runs the game on the first cpu core, through RunFirst.exe
# To be used only on some older games that don't run properly on multi-core cpus
run_first = 0
Expand Down Expand Up @@ -44,6 +48,10 @@ savegame_subdir =
# Running from another PC, username or game folder, will do the same
run_admin = 1

# ___ If specified, the following processes will be terminated before starting the game
# Add incompatible background processes here (executable names), separated by ', '
end_process =




Expand Down
Loading

0 comments on commit e6ec85b

Please sign in to comment.