The Top DSM Community on the Web

For 1990-1999 Mitsubishi Eclipse, Eagle Talon, Plymouth Laser, and Galant VR-4 Owners. Log in to remove most ads.

Please Support ExtremePSI
Please Support Rix Racing

ECMlink ECMLink Tips -n- Tricks: Saving and Restoring Multiple Layouts

This site may earn a commission from merchant
affiliate links, including eBay, Amazon, and others.

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Introduction

Have you ever wished that you could have different display setups in ECMLink that each have their own included items, fonts, colors, and graph properties...and be able to switch between them with a single mouse click? You can...and in this article I'll show you how.

You'll be able to easily switch from something like this:

You must be logged in to view this image or video.


to something like this:

You must be logged in to view this image or video.


...with a single (ehhhh... double) click of the mouse.

To accomplish this, we'll be tapping into the Windows registry where all of ECMLink's settings are stored. The basic idea consists of exporting the relevant registry keys to a file, making a small modification to it, and then double-clicking the file to restore the saved settings when desired.

NOTE: This article only applies to ECMLink running on MS Windows; those of you running on a Mac are on your own. You will also need to have administrative privileges, and access to a folder that has full read/write permissions to perform the steps below. (I would suggest storing the configuration files we will be creating on the desktop, or in a folder on the desktop).

This might appear to be complicated at first, but at the end of the article I'll condense everything down and you'll see just how simple it actually is.

What I describe in this article works great for me, but YMMV. I'm using Windows 7 , and ECMLink V3 (full) version 3.22.172; other OS or ECMLink versions may be slightly different, so pay attention and look everything over before jumping straight in head-first. As always, be sure to back up all of your files and have a contingency plan in case something goes horribly wrong and you end up disfigured for life. :D

Setting Up ECMLink

Setting up ECMLink for this doesn't involve anything more than getting things arranged like you want. Select the items to display, get them arranged the way you want, and set the font color, size, line style, and any other attributes as desired. For more information on optimizing ECMLink's display, you may want to check out this article.

Once everything is the way you like it, right click on the graph legend and click "Set all default preferences", and exit ECMLink. That's it!

The Windows Registry

Most people cringe at the thought of modifying (or even looking at) the Windows registry, but it's really not as bad as it's been made out to be. In fact, with even a little common sense, making changes to the registry is just as safe as modifying anything else on the computer. In a nutshell, the registry is nothing more than a group of files that are used to store information about how your computer and it's software works. Rather than get into a lot of detail about it, I'll keep it short and sweet in this article. If you want to know more (a lot more) about it, this is one of many excellent pages on the subject.

Although modifying the Windows registry is very simple and straightforward, it also comes with the risk of corrupting your PC to the point of needing a complete reload of the OS if you are careless and don't pay attention to what you are doing. If you don't feel comfortable with that, then find someone who is, or find another project to occupy your time with. Don't edit the registry drunk or while driving, and DO THIS AT YOUR OWN RISK!

Ok, now that all of that is out of the way...let's get on with it!

Note: If you are familiar with the registry and know how to edit it, you can skip to the next section.

To access the registry, we use a tool called RegEdit (the actual program file is regedit.exe, and can be found in the Windows/System32 folder). To launch the editor, simply go to the Start menu and type "regedit" (without the quotes) into the search bar, and hit enter. In most cases, you'll then see the lovely Windows UAC dialog box, asking if you are sure you want to do what you are sure you want to do:

You must be logged in to view this image or video.


Click Yes, and something that looks like an evil twin of the file explorer should open. It will resemble the image below, unless it's been opened before and the trees are already expanded.

You must be logged in to view this image or video.


Those five "folders" you see are actually called "hives", or "root keys". Under each hive are keys and sub-keys, and each key contains a set of data and it's values. You navigate through the tree just like in file explorer; click the arrows to expand and collapse different branches and work your way deeper into it.

The editor allows you to do many things, such as add, delete, and change keys and data values, export entire sections, and merge external files into the registry. Those last two are important, as that is what allows us to do what we are wanting.

Where is My ECMLink Stuff?

For our purpose, we are only interested in one particular key, which is found under the HKEY_CURRENT_USER hive. To get to it, expand HKEY_CURRENT_USER, then Software > JavaSoft > Prefs > ecmtuning > ecmlink. If you see more sub-keys called "data", "device", "filenames", etc. under the ecmlink key, then you are in the right place. You should be seeing something that looks like the following. Note that I have expanded all of the sub-keys under the main ecmlink key...more on this in a minute.

You must be logged in to view this image or video.


If you spend a little time clicking on the various sub-keys under "ecmlink" and looking over the data in the right pane, you'll quickly start to see how and where all of those values that you assigned in ECMLink are stored. It's actually pretty straightforward... paths and file names are under the "filenames" key, information about your connection properties is under "device", etc.

Note: You could change any of the parameter values in regedit and then re-open ECMLink, and you would see the new values. We won't need to do this though and I wouldn't recommended it anyway; just change values in Link as usual and let it worry about storing them to the registry.

For the purpose of this article, we are only interested in one key, which is the "data" key. It's full path name would be
Code:
[B]HKEY_CURRENT_USER\Software\JavaSoft\Prefs\ecmtuning\ecmlink\data[/B]
Make a note of this, as we will be using it again.

Note: To be more accurate, we really only need the 'displayvalues" key and the "views" key to save and restore the display, but it's easier just to work with the whole data branch. If you need to do something more advanced, like change the display configuration while also doing something weird with the sensor definitions for example, keep this in mind.

Now that we know where the data is stored, how it's organized, and which key we need, all that is left is to save it for future use. Fortunately, regedit makes this extremely easy to do. With the "data" key highlighted, right-click on it and select "Export". You will then be presented with a standard dialog asking for a file name and where you want to save it. Pick a meaningful name and choose a location that makes sense. For this example, let's use "Display_1" for the filename, and save it to the desktop. Click "Save" and a file called "Display_1.reg" will be created that contains all of your modified ECMLink display settings. At this point you can close regedit.

Just one more little detail to address...

As it turns out, ECMLink only stores certain data if it has been changed; most default values are assumed and not explicitly stored in the registry. What this means is that if you try to merge a saved configuration back into the registry that contained default values, some of that data won't be replaced, since the defaults weren't exported to begin with, and the registry now contains changed values. To get around this, we need to completely delete the "data" key first, and then merge the saved file back into the registry. This has the net effect of resetting all the defaults along with our saved custom values. Fortunately for us, this is simply a matter of adding one line to our saved .reg file.

NOTE: You could also just manually delete the "data" key from within regedit each time before merging the exported file back in, but the following approach is much better and only has to be done once.

Open the .reg file in any plain-text editor by right-clicking on it and then selecting "Edit". At the top you should see a header line similar to Windows Registry Editor Version 5.00, followed by a bunch of registry keys. What we want to do is insert a line right after the header that deletes the entire "data" key before the other lines are merged. The line we need to add is:

Code:
[-HKEY_CURRENT_USER\Software\JavaSoft\Prefs\ecmtuning\ecmlink\data]

Notice that this is the full path name to the "data" key inside brackets, with the addition of a hyphen (-) at the front of it. This tells regedit to first delete this key, and then merge the other lines into the registry when the .reg file is executed. The .reg file should look like this after you modify it (the inserted line is highlighted):

You must be logged in to view this image or video.


Save the file and close the editor, and your saved configuration file is ready to rock.

NOTE: Be careful if you use Wordpad or something other than Notepad to edit these files. Those other editors sometimes insert invisible formatting commands unless you specifically save the file as plain text.

Doing Something Useful

So we've saved our current ECMLink display settings to a file and modified it...now what? Well that depends on how creative you want to get. The simplest way to use this is to export the data key (don't forget to modify the file and add the line) for each layout that you create, using separate files for each. You can then simply double-click on whichever file you want to store them back into the registry, and then launch ECMLink as usual. If everything goes well, it will launch with the graph and legend configured exactly as it was when the configuration file was saved.

You creative types are probably seeing countless automation possibilities here. As you might expect, there is much, much more that you can do with this, including automating the export process, restoring settings each time ECMLink is launched, creating custom sensor setups, etc.

Wrapping It Up

So to condense all of this into something a little easier to follow...

To save ECMLink settings

1. Launch regedit from the start menu, and browse to the following key:
Code:
HKEY_CURRENT_USER\Software\JavaSoft\Prefs\ecmtuning\ecmlink

2. Right click on the "data" key, and click "Export", and save the file to a convenient location.

3. Open the saved file in notepad (right-click it and select "Edit"), and add the following line after the header line:

Code:
[-HKEY_CURRENT_USER\Software\JavaSoft\Prefs\ecmtuning\ecmlink\data]

4. Save the file.

To restore ECMLink settings

1. Double-click the saved file, answer Yes to any UAC prompts, and the saved data will be merged back into the registry.

2. Open ECMLink as usual and your restored settings should be happenin'.

Over the next few days, I'll add some more information on how to set up batch files and maybe even create some "buttons" that will completely automate the export process described above.

Stay tuned!


EDIT: For some reason, spaces are showing up in certain places such as "\ecmtunin g\", even though it looks fine in the editor. We are working on it, but in the mean time please ignore those spaces and be careful about copying and pasting.
 
Last edited by a moderator:
For you really lazy types (or really "efficient" types, as us really lazy types prefer to be called), I've written a batch file that will automate the process of exporting the registry key, adding the required line, and saving it to a file on your desktop. The idea is that you can click an icon on your desktop and it will do all of that ^ for you.

Before I give you the file and show you how to use it, we need to spend a little bit of time covering some basics. If you are familiar with DOS commands and batch files, feel free to jump ahead to the "ECMLink Export Utility" section below if you wish.

The Windows Command Processor

Most everyone is familiar with the Command Prompt (sometimes referred to as a command window or DOS shell), or has at least heard of it. This program is an internal command processor that allows you to manually type in system commands (also called DOS commands), to do things such as list files in a folder, get your computer's IP configuration, ping a remote computer, etc. It can be accessed from Start Menu > All Programs > Accessories, or by typing "command" or "cmd" in the start menu search bar.

Once you click on Command Prompt or cmd.exe, you'll see the following window appear:

You must be logged in to view this image or video.


You'll see the version and copyright info, and then a line showing the current folder you are in followed by a ">" and a blinking cursor. In the example above, that folder is "C:\Users\craig", which is my user folder and the one that the command processor runs in by default. The blinking cursor means that it is patiently waiting for me to enter a command and do something.

Note: "Command Prompt" is the user-friendly name; "cmd.exe" is the actual program file that runs. In earlier versions of Windows the file was called "command.com", but it's pretty much all the same thing. Microsoft operating systems have always included some version of the command processor; in fact, before Windows existed, that black screen and blinking prompt WAS the operating system! Anyone else remember turning on their first computer and being greeted with a blank screen and blinking white cursor? :)

If you've never used the command prompt, go ahead and give it a try. Open it up and type in "dir /p" (without the quotes) and press the enter key. You'll get a list of all the files and folders under your user folder, displayed one page at a time.

Note: The "/p" is called a command switch, and tells the dir command to pause instead of just continuing to scroll; pressing any key will show the next page (or you can cancel a command at any time by entering "CTRL+ c"). Most commands have several switches, the most important being "/?". Typing a question mark as a switch will list information about the command and all of the other switches available for it. For anyone that wants to learn more, this page is the official MS resource for commands and their use, and Windows CMD Commands also has a lot of info and examples.

Ok, enough of that. You could spend years learning how to do countless things in that window. That's not why you're here though, so let's move on...

Batch Files

While entering commands directly can be very useful, the real power of the command processor is it's ability to run several commands automatically that have been stored in a text file. This allows anyone with a little knowledge of programming and the available commands to automate almost any system-related task imaginable. This process is called DOS scripting, and the file that contains the commands is called a batch file...which is just a plain text file created in Notepad. A batch file has an extension of .bat or .cmd, and can be double-clicked and executed just like any other program. In addition to the common commands like "dir" and "ping", batch files can also contain commands that allow looping, branching, and conditional testing. With a little creativity, batch files can be used to pull off some pretty complex programming tasks when necessary.

Note: There are actually many different types of scripting languages available on different versions of Windows and other operating systems, such as Pearl, VBScipt, Bourn and "C" shells (UNIX), etc.. For the purposes of this article, "scripting" will refer to good old-fashioned DOS batch files using standard commands.

Rather than spending a lot of time on the various commands and how to use them, we'll just create a simple "Hello World!" program as an example. (There are several sites available with tons of information on the subject of batch files, such as [ame="http://en.wikipedia.org/wiki/Batch_file"]this one[/ame]).

For our example, open a new text document with Notepad and enter the following lines (or just copy and paste):

@echo OFF
REM This is a remark command and does nothing.
:: and so is this. The "::" is just a shortcut version of "REM"
REM Remarks are useful for commenting the batch file, or adding additional information
REM for anyone that may need to edit it in the future
ECHO Hello World!
ECHO.
ECHO.
PAUSE


Save the file to some place easily accessible (like the desktop), and then rename it to have an extension of ".bat" or ".cmd". Something like "MyBatchFile.bat" will be fine.

Note: The .bat extension is traditional, but more recent versions of Windows allow the .cmd extension which better denotes that the file can be executed like a program. To be safe on all versions, just stick with .bat. Also, commands aren't case sensitive, but it's common practice to write them using capital letters to make them stand out from other text in the file.

Once the file is saved and renamed, double-click it and it should execute. You should see a command window pop up that looks something like this:

You must be logged in to view this image or video.


So what's happening here? When you double-clicked the batch file, the command processor started and opened the command prompt window, and then executed the commands in the file, one line at a time.

  • The first line turned off the display of the commands in the file (which you don't need to see "echoed" to the screen).
  • The next four lines are remark commands that don't do anything; they are just used to document the file or add comments.
  • The next three lines printed "Hello World!" followed by two blank lines to the window, using the ECHO commands, and
  • The last line causes the window to remain open until you press a key.

Without the PAUSE command, the window would have just flashed and then closed; the script would still be executed, but you wouldn't see the results. Sometimes this is desired, but in this case we wanted to see the output, since creating some output to the screen is all we were doing anyway.

Obviously, this is about as simple a batch file as you'll ever see, and it doesn't do anything extremely useful. But no matter how complex, all batch files are created and executed in this same manner; the only thing that changes are the commands that they contain.

Now that you know what a batch file is and how to create one, let's get down to business.

ECMLink Export Utility

The following batch file will allow you to automatically save the current ECMLink display configuration. When it is launched, it will:

1. Open a command prompt and ask for the name of the file you want to save the current ECMLink configuration to. This can be any name you want; use something descriptive so you will remember which one it is. By default, the file will be saved to the desktop; you can modify one line in the batch file to change this location if desired.

2. Automatically export the ecmlink data key, and then read the header text so that it can be written to another file later.

3. Create a temporary file and write the header text from above, and insert the line that is used to delete the data key and reset the display defaults.

4. Copy the exported values into the temporary file after the inserted line, and then move and rename the temporary file to the desktop, using the name you specified.

DISCLAIMER

I've tried to incorporate some error handling and make this batch file as "friendly" as possible, and have tested it repeatedly with no problems. But as usual, YMMV and I accept no responsibility for melted computers, missing fingers, deformed kids, or anything else that may happen.


If you encounter any problems with it, make sure you have administrative privileges and can a write to your temp folder. If it reports a "Registry key not found" error, use regedit as described above and verify that the registry structure is the same.


To create the batch file, right-click anywhere on your desktop and select New > Text Document. Double-click the new file to open it in Notepad, and then copy and paste the text in the following code box into it (I've colored the remarks green in the listing below so they are easier to see).

Code:
@ECHO OFF
TITLE ECMLink Configuration Export Utility

[COLOR="Green"]::	This batch file will save an ECMLink configuration file to your desktop. If you want to save it somewhere
::	else, replace "%USERPROFILE%\Desktop\" in the line below with the folder you want to use. Be sure to include 
::	the "\" at the end of the line, and no spaces after the equal sign.[/COLOR]

set pathvar=%USERPROFILE%\Desktop\

[COLOR="green"]::	This section will ask you for the filename, and allow you to cancel the save[/COLOR]

:GETFILENAME
CLS
ECHO.
SET /p filename=Enter a name for the configuration file: 
IF /I "%filename%"=="" (GOTO GETFILENAME)

:PROCEED
ECHO.
SET /p yn=Save ECMLink data? (y)es, (n)o, or (c)ancel 
IF /I "%yn%"=="c" (GOTO END)
IF /I "%yn%"=="n" (GOTO GETFILENAME)
IF /I "%yn%"=="y" (GOTO SAVEDATA) else (echo Please enter y, n, or c) & (GOTO PROCEED)

[COLOR="green"]::	Export the "data" key to a temporary file so we can strip out just the key information
::	">NUL" suppresses standard output of a command, and "2>NUL" suppresses error output[/COLOR]

:SAVEDATA
ECHO.
SET finalFileName=%pathvar%%filename%.reg
SET tempRegFile1=%TEMP%\regtmp1.txt
SET tempRegfile2=%TEMP%\regtmp2.txt
REG EXPORT "HKEY_CURRENT_USER\Software\JavaSoft\Prefs\ecmtuning\ecmlink\data" %tempRegFile1% /y >NUL 2>NUL
IF %errorlevel% NEQ 0 GOTO REGERROR
ECHO.

[COLOR="green"]::	Get the first line (header) of the exported reg file, so it can be rewritten later[/COLOR]

FOR /f "tokens=*" %%i IN ('type %tempRegFile1%') DO SET headerText=%%i & GOTO :1
:1

[COLOR="green"]:: 	Create the final reg file, add the header and new line, and then populate it with the rest
::	of the exported registry data[/COLOR]

SET newline=[-HKEY_CURRENT_USER\Software\JavaSoft\Prefs\ecmtuning\ecmlink\data]
@ECHO OFF > %tempRegFile2%
ECHO %headerText% >> %tempRegFile2%
ECHO. >> %tempRegFile2%
ECHO %newline% >> %tempRegFile2%
ECHO. >> %tempRegFile2%
FOR /f "skip=2 delims=" %%l IN ('type %tempRegFile1%') DO (>> %tempRegFile2% echo.%%l)

[COLOR="green"]::	Rename the final temporary file to the user-selected filename, if there were no errors[/COLOR]

IF EXIST %tempRegFile2% (   
    MOVE /Y %tempRegFile2% %finalFileName% >NUL
    DEL %tempRegFile1%
    ECHO ECMLink configuration saved to %finalFileName%
) ELSE (
    ECHO Unable to create temporary file. Configuration was not saved.
)

ECHO.
ECHO.
PAUSE

:END
EXIT

:REGERROR
ECHO.
ECHO Registry key not found; configuration was not saved. 
ECHO.
PAUSE
EXIT

Save the file, and rename it to "ECMLinkSave.bat" (or whatever you want as long as it ends with ".bat" or ".cmd"). To launch the program and save your ECMLink settings at any time, simply double-click the icon.

When the program runs, you should see this:

You must be logged in to view this image or video.


Enter a file name and then select "y" to continue, "n" to re-enter the file name, or "c" to cancel and exit. Once the file is saved successfully, you'll see the following message and the window can be closed.

You must be logged in to view this image or video.


Your current ECMLink display configuration is now saved to the desktop as a reg file:

You must be logged in to view this image or video.


...and can be restored at anytime by double-clicking it and answering yes to any prompts.
 
Last edited by a moderator:
Support Vendors who Support the DSM Community
Boosted Fabrication ECM Tuning ExtremePSI Fuel Injector Clinic Innovation Products Jacks Transmissions JNZ Tuning Kiggly Racing Morrison Fabrications MyMitsubishiStore.com RixRacing RockAuto RTM Racing STM Tuned

Latest posts

Build Thread Updates

Vendor Updates

Latest Classifieds

Back
Top