What is a script and why use it! #
When using an emulator with mGalaxy, 2 criteria are induced:
- the emulator must be able to run in full screen.
- you must be able to exit the emulator by pressing the ‘ESC’ key.
Sometimes an emulator will not allow to specify one or all of these 2 settings in the application. In this case, you need a ‘script’ to assist the emulator.
A script is a small piece of software between mGalaxy and the emulator to execute tasks that are not natively provided by the emulator.
mGalaxy comes with all the necessary scripts pre-installed but if you need to add an emulator not yet recognized by mGalaxy and also the necessary script, here is how to proceed.
The script must be located in the “Scripts” folder of mGalaxy and have exactly the same name as the one given to the emulator. Finally, you must make sure that the system informing this emulator (and therefore the corresponding script) has the box “Use script file if available” checked.
Creating a script with ‘AutoIt’ #
AutoIt is a freeware BASIC-like scripting language designed for automating the Windows GUI and general scripting. It uses a combination of simulated keystrokes, mouse movement and window/control manipulation in order to automate tasks.
• First you will need to download and install the AutoIt freeware here.
• Create a script that must start with the code below.
;----------========== Parsing (common to every scripts) ==========---------- ; The script is being passed 2 parameters by mGalaxy. ; The first one contains the full path to the emulator. ; The second one contains parameters (optional) for the emulator PLUS the full path (between quotes) to the rom file. ; ; Line 13: $CmdLine is an array of size 3. $CmdLine returns the total number of items in the array, $CmdLine the 1st parameter, $CmdLine the 2nd parameter ; Line 19: AutoIt requires that parameters sent by mGalaxy be enclosed in quotation marks. ; As the parameters themselves contain quotation marks, these have been replaced by a distinguishing sign (%s) so as not to cause any confusion in the constitution of the command line. ; So we now replace this distinguishing sign with quotation marks. ; Line 20: Some apps (MESS for instance, when it searchs for a system Bios) need to know the path to their 'Working Directory'. We do extract it from the emulator full path. ; #include <MsgBoxConstants.au3> If UBound($CmdLine) <> 3 Then MsgBox($MB_SYSTEMMODAL, "Script execution error", "The script was expecting to receive 2 parameters but received " & UBound($CmdLine)-1, 10) Exit 0 EndIf local $app = $CmdLine local $command = StringReplace($CmdLine, "%s", """") Local $workingDir = StringRegExpReplace($app, "\\[^\\]*$", "") FileChangeDir($workingDir) ;---------------------------------------------------------------------------