Jump to content
LaunchBox Community Forums

My version of SumatraPDF + Autohotkey + JoyToKey. AND Feature Request: support for .bat (batch file) as "game manuals" for the "Game Pause Menu".


Recommended Posts

Posted (edited)

   Disclaimer #1: I create this post just to share my way viewing multiple and different file/file types/documents and/or Images together in a single screen setup and move between them with the controller.

   Disclaimer #2: I'm not an expert at all in any of this, neither in the applications nor in batch scripts. I managed to do it just by searching, reading and A LOT OF TESTING, so please bear with me if you find anything that doesn't look right or perhaps needs to be changed for whatever reason.
  
That being said, please don't expect me to be able to help/troubleshoot everything (even though I could try my best 😅) nor (maybe) receive requests, there are many members around the forums who are truly experts in scripting/coding and maybe can/willing to help more than I can, so if you are experiencing any issues or need help at anything feel free (of course) to post it below for discussion, but don't count only on me to be able to find the solution although I would love to. 😅 ☺️


Alright, so here how it goes...

Part 1:

- My version of SumatraPDF + Autohotkey + JoyToKey.

   Long ago (2016) I came across -this- @fasm's thread about using SumatraPDF as a pdf viewer for reading game manuals and I gave it a try. It was a nice idea to use a pdf viewer other than the default one.
   A Little later (2017) I came across -this- @teeedubb's and -this- @KUPOkinz's threads about using SumatraPDF and Autohotkey (and another app) to be able to read the manuals also without leaving my hands off the controller, I gave it a try also and it was working nicely.

So a HUGE shout-out to all of them for helping/inspiring me found my own “path” beside them. 😄

   After some time (in 2024) I had this idea to create my own version of SumatraPDF + Autohotkey combination through a "simple" batch file which could open multiple files/file-types (as long SumatraPDf supports them -see here-) from just one file, the 'Game manual' itself. (In my version I make use also of ‘Nircmd’ to just manipulate the app and/or the cmd window to my needs such as start minimized, maximized, set on-top etc.)

 

Now let’s get to the point.

   The basic idea is to have the batch file take the place of your game manual which when used identifies the folder where is placed in and also the filename it has and looks under a specified custom directory for that same path/folder OR file name base on its filename and open the file(s) found with SumatraPDF combined with the use of Autohotkey for some automation moves (eg. To “hide” the mouse pointer), JoyToKey for controller support and Nircmd for some window manipulation and error/info messages.

 

Below are the links to the applications used:

1. SumatraPDF (choose the portable version) -link-
2. Autohotkey (V2) (prefer the portable zip version) -link-
3. JoyToKey (prefer the portable zip version -manual installation-) -link-
4. Nircmd [x64] (scroll down to the end of the page) -link-

Below is a sample image so you get the picture on how the batch files and the actual document manuals are placed so they work:

treeexample.png.468b8178c6f7804ebf406b9fc6b0adaa.png

- NOTE #1: The Platform Name (in RED) matches the name of the LaunchBox platform
- NOTE #2: In this situation (in ORANGE) the bat file is calling one file per game as long as the name of each file (no matter the extension) matches the batch file name and the Platform it is sitting in also match the folder of the file.
- NOTE #3: In this situation (in PURPLE) the same bat file is calling multiple files per game (no matter the extension) as long as the name of each folder matches the name of the batch file and the Platform it is sitting in also match the parent folders name.

* If any of the above matching is not happening then the batch file shows a message of what is not found.

As for the third party apps you are free to place them where ever you want as long as you point them correctly in the batch script.

As reference here is where I’ve put mine:

SumatraPDF: G:\TOOLS\SumatraPDF\SumatraPDF.exe
AutoHotkey: G:\TOOLS\AutoHotkey\AutoHotkey64.exe
JoyToKey: G:\TOOLS\JoyToKey\JoyToKey.exe
Nircmd: G:\TOOLS\Nircmd-x64\Nircmd.exe
 

·         After placing the apps above in their own directories use the file below as the AutoHotKey script:
SumatraPDF-JoyToKey.ahk (After downloading remember to right-click>properties>unblock)
and place it also in a folder. (I choose to put it inside the G:\TOOLS\AutoHotkey folder beside Autohotkey.exe)

*Posting below the same Autohotkey script for reference (open with/paste it into Notepad++ for proper reading):

#SingleInstance force

SetWorkingDir(A_ScriptDir)

#Warn

Sleep(1000)                                                                                                                                                                                                                                        ;Wait 1 second.

if WinWaitActive("SumatraPDF ahk_exe SumatraPDF.exe", , 2)                                 ;Wait for 2 seconds for SumatraPDF to open then

{

   CoordMode("Mouse", "Screen")                                                                                                                                                          ;Move the mouse

   MouseMove(A_ScreenWidth/1, A_ScreenHeight/2)                                                                                   ;to the side of the screen and

   WinActivate("SumatraPDF ahk_exe SumatraPDF.exe")                                                                              ;activate SumatraPDF.

}

;Send "^+l"                                                                                                                                                                                                                                         ;SumatraPDF Presentasion mode.(commented)

   else                                                                                                                                                                                                                                                     ;If SumatraPDF (from WinWaitActive) fail to open then

   ProcessClose("joytokey.exe")                                                                                                                                                                ;close joytokey process.

ProcessWaitClose("SumatraPDF.exe")                                                                                                                                   ;After SumatraPDF loads wait for it to exit and

ErrorLevel := ProcessExist("joytokey.exe")                                                                                                          ;close joytokey after that.

if ErrorLevel

{

  ProcessClose("joytokey.exe")

}

 

·         Then here is the SumatraPDF configuration file for using JoyToKey with SumatraPDF for the controller:
SumatraPDF.cfg (After downloading remember to right-click>properties>unblock)
(I think that this one MUST be inside  ..\JoyToKey folder beside JoyToKey.exe, I put mine in G:\TOOLS\JoyToKey)

Controller configuration below (XINPUT):

D-pad or Left Stick UP/Down: Scroll Up/Down slow                         Game-Pad A: Move to last page
D-pad or Left Stick Left/Right: Next/Previous page                          Game-Pad B: Page rotate left
Right Stick UP/Down: Scroll Up/Down fast                                          Game-Pad X: Page rotate right
Right Stick Left/Right: Next/Previous page fast                                 Game-Pad Y: Move to first page

Back: Exit   Start: Full-screen toggle   Left Trigger (Analog): Zoom out   Right Trigger (Analog): Zoom in

Left Bumper: Previous tab   Right Bumper: Next tab   Left Stick Push: Normal view   Right Stick Push: Fit page view

NOTE: Perhaps you might need to change the controller-buttons to fit your needs.

 

·         The AppLink data file which is the file that tells JoyToKey to “auto engage” the specific profile when SumatraPDF is active.
AppLink.dat (After downloading remember to right-click>properties>unblock)
(This one MUST DEFINITELY be inside  ..\JoyToKey folder beside JoyToKey.exe, I put mine in G:\TOOLS\JoyToKey)

*ATTENTION: Before using JoyToKey open AppLink.dat file with any text editor (preferably Notepad++) and change the PATH-TO-SUMATRAPDF part with the actual path you are using (eg. G:\TOOLS\SumatraPDF)
NOTE: You can skip the drive letter here also if you are aiming for portability. (eg. \TOOLS\SumatraPDF) 

 

·         And lastly here is the batch/script file you can get from below:
Multi Manual Launcher.bat (After downloading remember to right-click>properties>unblock)

NOTE: Remember to replace the PATH-TO-... parts with your actual paths you are using and Change the name of the bat file to match the game title in LaunchBox each time (preferably using Notepad++'s Replace function for convenience).

NOTE: You can if you want use any file-name as long as you make sure the target’s [folder or file] name matches the batch file-name exactly but then you must point LaunchBox to it manually in the Edit Game>Media>Game manual path.

I am also posting below the batch script from above for reference (open with/paste it into Notepad++ for proper reading):

@echo off

title Multi Manual Launcher

if not defined IS_MINIMIZED set IS_MINIMIZED=1 && start "" /min "%~dpnx0" %* && exit

start /wait "" "PATH-TO-NIRCMD\Nircmd.exe" win min title "Multi Manual Launcher"

 

::Setting-up the Main +Manuals directory

set Dir=PATH-TO-REAL-MANUALS (eg.G:\Real Manuals)

 

::Searching inside '%Dir%' for the same directory as the folder of this batch file

cd %Dir%

for %%b in ("%~dp0.") do set "DirName=%%~nxb"

::If the name of the '%Dir%' matches the folder-name of this batch file '%%~na'

for /d /r "%Dir%" %%a in (*) do if /i "%%~na" == "%DirName%" goto FOUND

 

:PLATFORM_NOT_FOUND

start /wait "" "PATH-TO-NIRCMD\Nircmd.exe" infobox "The '%DirName%' Platform folder you specified does not currently found inside the '%Dir%' directory!" "Attention!"

timeout /T 1 /nobreak >nul

start /wait "" "PATH-TO-NIRCMD\Nircmd.exe" win activate title "Attention!"

 

exit

 

:FOUND

:FOUND_FILES

::Search RECURSIVELY INSIDE ALL OF THE FOLDERS WITHIN THE '%DIRNAME%' for the FILES WITH THE SAME FILE-NAME (not extension) with

:: this batch file

cd %DirName%

for /r %%f in (*) do if /i "%%~nf" == "%~n0" (

::and open them with SumatraPDF.

                start "" "PATH-TO-SUMATRAPDF\SumatraPDF.exe" "%%~pnxf" -presentation

                start /wait "" "PATH-TO-NIRCMD\Nircmd.exe" win max ititle "%%~nxf"

                start /wait "" "PATH-TO-NIRCMD\Nircmd.exe" win settopmost ititle "%%~nxf"

) & goto END

 

:FOUND_FOLDERS

::Search for ALL OF THE FOLDERS WITHIN THE '%DIRNAME%' for the FOLDERS WITH THE SAME FILE-NAME (not extension) with

:: this batch file and OPENS EVERY FILE INSIDE (recursively) THEM REGARDLESS OF THE FILENAME,

cd %DirName%

for /d %%f in (*) do if /i "%%~nxf" == "%~n0" (

    cd %%~nxf

                for /r %%g in (*) do (

::with SumatraPDF.

                start "" "PATH-TO-SUMATRAPDF\SumatraPDF.exe" "%%~pnxg" -presentation

                start /wait "" "PATH-TO-NIRCMD\Nircmd.exe" win max ititle "%%~nxg"

                start /wait "" "PATH-TO-NIRCMD\Nircmd.exe" win settopmost ititle "%%~nxg"

)) & goto END

 

:NAME_NOT_FOUND

set file_name=%~n0

start /wait "" "PATH-TO-NIRCMD\Nircmd.exe" infobox "The '%file_name%' Folder or File you specified does not currently found inside the '%Dir%\%DirName%' Platform directory!" "Attention!"

timeout /T 1 /nobreak >nul

start /wait "" "PATH-TO-NIRCMD\Nircmd.exe" win activate title "Attention!"

 

exit

 

:END

start "" "PATH-TO-JOYTOKEY\JoyToKey.exe"

start "" "PATH-TO-AUTOHOTKEY\AutoHotkey64.exe" "PATH-TO-AUTOHOTKEY\SumatraPDF-JoyToKey.ahk"

 

exit


NOTE: You can skip the drive letter [D:\, G:\, etc.] if you're aiming for portability replace the G:\ with just the \

NOTE #2: Whenever is possible in ahk or bat script I put comments so that is clear what its line is supposed to do.

Conclusion of the first part:

As I said on the top feel free to ask anything, change anything you might think is worth changing and if you want share with the rest of us your ideas or your own “version” 😃

I've been using the above setup for quite some time (almost a year) and everything seems to work perfect (for me at least) if you get the idea/hang of it will be as easy as copy/paste/rename. 😀

 
Part 2:

- Feature Request: Support for .bat (batch file) as game manuals for the "Game Pause menu"

   As of all the above works perfect from inside LaunchBox's right-click menu>View Manual and/or BigBox's Game menu>View Manual, the “Documents” are showing in SumatraPDF exactly as intended BUT when it comes to 'Pause Menu' the bat file is opened like text ! 😒

   So I made -this- feature request so that the 'Pause Menu' can ALSO support the batch scripts/.bat files in place of the game manual and not viewing them as text.

   It fills a bit odd that something that is working from the LaunchBox and BigBox menu does not work also from the Pause menu. I understand somewhat that the pause menu stands on its own code but it’s the support for that file type that it needs. 🤔

So if after all you still found the above setup useful you might also consider up-voting the above feature request.


Thank you for your time in reading all this and please let me know your thoughts. 😄

Edited by Tsik

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...