markmon Posted January 28, 2017 Share Posted January 28, 2017 Ok here is an example of how I do this exact thing using an AHK script for pscx2. I have a set up that determines which game config to use based on the game that is being requested by the front end. In this case, the front end passes full path and rom name. I extract the full path and rom, use AHK function SplitPath which extracts just the romname, then substr to grab the name of the rom without the extension (.iso or such). From there, I am running my own script that knows the rom passed in. In my case, I then check for whether or not a config with that rom name exists and if so I launch pscx2 with config. Otherwise we use default config. I call this launchboxstartps2.exe and I told launchbox that pcsx2.exe is actually launchboxstartps2.exe. Here is my script: #SingleInstance force ;Prevent multiple instances #WinActivateForce ;Hopefully makes pinball fx window activate. exitEmulatorKey = Esc SetWorkingDir, H:\Game Launcher\Theater\pcsx2 GameName = %1% SplitPath, GameName, ConfigGame ConfigName := SubStr(ConfigGame, 1, -4) ConfigBase = H:\Game Launcher\Theater\pcsx2\gamesettings ConfigPath = %ConfigBase%\default Hotkey, $%exitEmulatorKey%, ClosePcsx2 ifExist, %ConfigBase%\%ConfigName% ConfigPath = %ConfigBase%\%ConfigName% RunWait, "pcsx2.exe" "%GameName%" --cfgpath="%ConfigPath%" --fullscreen,,UseErrorLevel ExitApp ClosePcsx2: Hotkey, %exitEmulatorKey%, Off Process, Close, pcsx2.exe Quote Link to comment Share on other sites More sharing options...
igotdvds Posted January 28, 2017 Share Posted January 28, 2017 12 hours ago, markmon said: Ok here is an example of how I do this exact thing using an AHK script for pscx2. I have a set up that determines which game config to use based on the game that is being requested by the front end. In this case, the front end passes full path and rom name. I extract the full path and rom, use AHK function SplitPath which extracts just the romname, then substr to grab the name of the rom without the extension (.iso or such). From there, I am running my own script that knows the rom passed in. In my case, I then check for whether or not a config with that rom name exists and if so I launch pscx2 with config. Otherwise we use default config. I call this launchboxstartps2.exe and I told launchbox that pcsx2.exe is actually launchboxstartps2.exe. Here is my script: #SingleInstance force ;Prevent multiple instances #WinActivateForce ;Hopefully makes pinball fx window activate. exitEmulatorKey = Esc SetWorkingDir, H:\Game Launcher\Theater\pcsx2 GameName = %1% SplitPath, GameName, ConfigGame ConfigName := SubStr(ConfigGame, 1, -4) ConfigBase = H:\Game Launcher\Theater\pcsx2\gamesettings ConfigPath = %ConfigBase%\default Hotkey, $%exitEmulatorKey%, ClosePcsx2 ifExist, %ConfigBase%\%ConfigName% ConfigPath = %ConfigBase%\%ConfigName% RunWait, "pcsx2.exe" "%GameName%" --cfgpath="%ConfigPath%" --fullscreen,,UseErrorLevel ExitApp ClosePcsx2: Hotkey, %exitEmulatorKey%, Off Process, Close, pcsx2.exe I completely understand this but how is your LB configured? What command line parameters allow you to read them here? Quote Link to comment Share on other sites More sharing options...
Crush Posted January 28, 2017 Share Posted January 28, 2017 (edited) You send all command line parameters through the ahk script. Here's my Hoxs64 ahk script - modified with markmon's suggestion so i can read the rom name outside LB - it maps various joystick buttons to Save State, Load State, Wrap on/off, e.t.c and uses the romname to save/load game states. I compiled the script to .exe and use it as the emu executable instead of hoxs64.exe (so i don't have to setup any ahk scripts or command line parameters in LB) #SingleInstance force #WinActivateForce SetWorkingDir, D:\Emu\C64\hoxs64 GameName = %1% SplitPath, GameName, rom_name rom_name := SubStr(rom_name, 1, -4) RunWait, "hoxs64.exe" -fullscreen -autoload "%GameName%" ; Exit emu esc:: Send !{F4} ExitApp Return 4Joy17:: Send !{F4} ExitApp Return ; Change Disc 4Joy2:: Send !{enter} Sendinput {Alt Down} Sendinput {D} Sendinput {I} Sendinput {E} Sendinput {Alt Up} WinWait, Choose a disk image file WinWaitClose Send !{enter} Return ; Switch Joysticks 4Joy7:: Send !{j} Return ; Warp mode On/Off 4Joy15:: Send !{q} Return ; Load State 4Joy18:: IfExist D:\Emu\C64\hoxs64\States\%rom_name%.64s Send !{enter} Sendinput {Alt Down} Sendinput {F} Sendinput {Alt Up} Send {Down 5} Send {Enter} WinWait, Load Send %rom_name%.64s Send {Enter} Send !{enter} Return ; Save State 4Joy19:: Send !{enter} Sendinput {Alt Down} Sendinput {F} Sendinput {Alt Up} Send {Down 6} Send {Enter} WinWait, Save Send %rom_name% Send {Enter} IfExist D:\Emu\C64\hoxs64\States\%rom_name%.64s Send {Alt Down}{Y}{Alt Up} Send !{enter} Return ; Pause 4Joy20:: Send !{p} Return Edited January 28, 2017 by Crush Quote Link to comment Share on other sites More sharing options...
igotdvds Posted January 28, 2017 Share Posted January 28, 2017 1 hour ago, Crush said: You send all command line parameters through the ahk script. Here's my Hoxs64 ahk script - modified with markmon's suggestion so i can read the rom name outside LB - it maps various joystick buttons to Save State, Load State, Wrap on/off, e.t.c and uses the romname to save/load game states. I compiled the script to .exe and use it as the emu executable instead of hoxs64.exe (so i don't have to setup any ahk scripts or command line parameters in LB) #SingleInstance force #WinActivateForce SetWorkingDir, D:\Emu\C64\hoxs64 GameName = %1% SplitPath, GameName, rom_name rom_name := SubStr(rom_name, 1, -4) RunWait, "hoxs64.exe" -fullscreen -autoload "%GameName%" ; Exit emu esc:: Send !{F4} ExitApp Return 4Joy17:: Send !{F4} ExitApp Return ; Change Disc 4Joy2:: Send !{enter} Sendinput {Alt Down} Sendinput {D} Sendinput {I} Sendinput {E} Sendinput {Alt Up} WinWait, Choose a disk image file WinWaitClose Send !{enter} Return ; Switch Joysticks 4Joy7:: Send !{j} Return ; Warp mode On/Off 4Joy15:: Send !{q} Return ; Load State 4Joy18:: IfExist D:\Emu\C64\hoxs64\States\%rom_name%.64s Send !{enter} Sendinput {Alt Down} Sendinput {F} Sendinput {Alt Up} Send {Down 5} Send {Enter} WinWait, Load Send %rom_name%.64s Send {Enter} Send !{enter} Return ; Save State 4Joy19:: Send !{enter} Sendinput {Alt Down} Sendinput {F} Sendinput {Alt Up} Send {Down 6} Send {Enter} WinWait, Save Send %rom_name% Send {Enter} IfExist D:\Emu\C64\hoxs64\States\%rom_name%.64s Send {Alt Down}{Y}{Alt Up} Send !{enter} Return ; Pause 4Joy20:: Send !{p} Return What dictates what %1% returns? What does %2% return? Is there a %3%? How is markmons script calling %platform%? Quote Link to comment Share on other sites More sharing options...
Crush Posted January 28, 2017 Share Posted January 28, 2017 %1% is the first command line parameter, %2% the second, e.t.c When running a game, LB usually sends the romname (including path) after the emu executable so if you run Archon.g64 with Hoxs64.exe, the command line will be something like: D:/emu/c64/hoxs64/Hoxs64.exe D:/emu/c64/games/archon.g64 So %1% will hold "D:/emu/c64/games/archon.g64" Quote Link to comment Share on other sites More sharing options...
igotdvds Posted January 29, 2017 Share Posted January 29, 2017 5 hours ago, Crush said: %1% is the first command line parameter, %2% the second, e.t.c When running a game, LB usually sends the romname (including path) after the emu executable so if you run Archon.g64 with Hoxs64.exe, the command line will be something like: D:/emu/c64/hoxs64/Hoxs64.exe D:/emu/c64/games/archon.g64 So %1% will hold "D:/emu/c64/games/archon.g64" So how would I use the new %gameid% feature? I added a new exe and left no parameters defined. It output the rom path as %1% but nothing for %2% or %3%. How can I get %platform%, etc. to work? Quote Link to comment Share on other sites More sharing options...
markmon Posted January 29, 2017 Share Posted January 29, 2017 If you have added an exe like we are describing above, then you know your platform as that exe replaces only one emulator. In the example above you know your platform is c64. In my example with pcsx2, I know my platform is ps2. Quote Link to comment Share on other sites More sharing options...
AgoustBolchz Posted September 25, 2018 Share Posted September 25, 2018 Hi, I apologize for bringing this back to life but you guys @ckp @markmon brought something that might help me and in the thread I created no one could. Stella's games don't open within my LB (nothign happens), but I can right click and "open Stella" to open the emulator and choose the game from the emulator's interface. So, considering that outside of LB the emulator works fine, we all got to the conclusion that there's a problem with the path LB chooses for the emulator. I tried reinstalling, I tried EVERYTHING. What I would like to know is the path commands to confirm our theories. I tried with the msgbox ahk that Mark recommended and got this error (image attached). I tried the batch file that CKP recommended with echo to test.txt but it remains empty. Any idea? Thank you in advance and I apologize for bothering. Is there any way in which we can follow this elsewhere so I don't bother the rest? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.