Best iMacros workarounds, hacks, tipps and tricks

imacros tipps and tricks

iMacros is a simple and powerful browser plugin for webautomatation. By using a build-in record function, you can login into an account, fill out forms or do bulk actions.

I often came to a point where I wanted to automate something which was simply programming logic but seemed quite impossible with iMacros. After some intensive research and testing I build myself a little “knowledge book” with solving issues.

As a consequence of many unknown solutions for several wildly seen issues, created I this post with the best iMacros workarounds, hacks, tipps and tricks.

iMacros tricks

The developers of iMacros haven’t implemented the if else statement for iMacros which we know from Javascript, Java and many other programming languages.
For those who don’t know what an if else statement is, in short: “The if statement executes a statement if a specified condition is true. If the condition is false, another statement can be executed.” (Source: Mozilla)

To use an if else statement in iMacros we make use of some Javascript code, the Eval, which can be used within our iMacros script.

This is an description of how to use it. You can simply copy&paste and apply it to your needs:

SET !VAR1 variable/text 1
SET !VAR2 variable/text 2

SET !VAR3 EVAL("var X=\" {{!VAR1}} \"; var Y=\" {{!VAR2}} \"; if (X < Y){var x = \" statement 1 \";} else {var x=\" statement 2 \";} x;")

So what the code above does is, it assigns each !VARx an integer (=number) or string (=text)
It then assigns inside the EVAL code each !VAR another variable letter, in this case X and Y. Watch out when not using strings (=text) to remove the \” character because a string (=text) is indicated by adding those backslash with quotes. After the second assignment, it checks by the if what your conditions are. In this case if the variables would be numbers it would check if number Y was bigger then number X. Possible conditions which you can check are:

  • (X < Y) - if Y is stricly bigger than X
  • (X > Y) – if X is strictly bigger than Y
  • (X == Y) – if Y is the same as X
  • (X <= Y) - if Y is bigger or equal as X
  • (X >= Y) – if X is bigger or equal as Y

They can all be used for integers (=numbers) and strings (=text)
If the condition is true, it returns the first statement1. If not it returns the second statement2.

Finally, you can use that kind of information as !VAR3

You can also test this existing example of the conditional statement:

SET !VAR1 "4"
SET !VAR2 "15"

SET !VAR3 EVAL("var number1=\"{{!VAR1}}\"; var number2=\"{{!VAR2}}\";  if ( number1 < number2 ) {var x = \" {{!VAR1}} is bigger then {{!VAR2}}\";} else {var x=\"{{!VAR2}} is bigger then {{!VAR1}}\";} x;")

iMacros can be used with both, Javascript and iMacros script. Javascript comes in handy when it comes to more sophisticated automation. However the simplest actions are done via iMacros recording and playing them.

It is possible to use iMacros codes in Javascripts which is described on their wiki page with the iimPlay() function.
In short:

  • add a line with a variable: var macro;
  • define the variable as a “CODE:”
  • duplicate each line of your iMacros code, however by adding macro +=  ” before and ” + “\n”; at the end.
  • add on the last line: iimPlay(macro)

And that is how you convert your iMacros code to Javascript manually.

The cool thing is, there’s a easier and fast way. I once found a program on the net which does the same thing however with bugs. So i took the idea, and created a software with the same function but bugfree.

Simply paste your code, and you’ll recieve the converted code.

iMacros Java Script Converter

For more information and  FREE download visit my link below

iMacros Javascript Converter


I came several times to the point where I thought: “Wow. This is such a great code, I need to protect it so nobody can edit it or know what the source is”.
There actually are ways to protect your iMacros code. However, everybody with some coding skills may find the source of it and the iMacros sidebar will still show the code while it’s playing.  So THIS WILL NOT protect your files like the .iimx from Enterprise Edition, but it’s currently the best, easiest and fastest way on how you can achieve it.

For this example, we will use a simple iMacros script which we’re going to protect from beeing edited or read.

PROMPT "This post was created: {{!EXTRACT}}"

This iMacros script is simply telling us that this post was created on the 7th September 2016.

  1. Download the iMacros to Java Script converter
    This is needed to convert our whole iMacros scripts into .js
  2. Copy and paste the WHOLE script into iMacros Script Code Creator and Convert it to Java Script String:
    protect secure imacros scripts
  3. Copy the whole output EXCEPT the first and last line which are always:
    var macro;

    So the code we would copy is:

    macro =  "CODE:";
    macro +=  "SET !EXTRACT_TEST_POPUP NO" + "\n";
    macro +=  "URL GOTO=" + "\n";
    macro +=  "TAG POS=1 TYPE=SPAN ATTR=TXT:September* EXTRACT=TXT" + "\n";
    macro +=  "PROMPT \"This post was created: {{!EXTRACT}}\"" + "\n";
  4. Head over to Java Script obfuscator, paste the whole code into it and obfuscate it.
    protect secure imacros scripts
  5. Create a new Example.iim file (where all your other .iim scripts are located) and rename it to something Example.js
  6. Now copy and paste the whole obfuscated code in Example.js and add var macro; in the first line and iimPlay(macro) in the last line. Our finaly code then looks like this:
    var macro;
    var _0x2d09=["\x43\x4F\x44\x45\x3A","\x53\x45\x54\x20\x21\x45\x58\x54\x52\x41\x43\x54\x5F\x54\x45\x53\x54\x5F\x50\x4F\x50\x55\x50\x20\x4E\x4F","\x0A","\x55\x52\x4C\x20\x47\x4F\x54\x4F\x3D\x68\x74\x74\x70\x73\x3A\x2F\x2F\x78\x73\x2D\x73\x6F\x6C\x2E\x63\x6F\x6D\x2F\x62\x65\x73\x74\x2D\x69\x6D\x61\x63\x72\x6F\x73\x2D\x77\x6F\x72\x6B\x61\x72\x6F\x75\x6E\x64\x73\x2D\x68\x61\x63\x6B\x73\x2D\x74\x69\x70\x70\x73\x2D\x74\x72\x69\x63\x6B\x73\x2F","\x54\x41\x47\x20\x50\x4F\x53\x3D\x31\x20\x54\x59\x50\x45\x3D\x53\x50\x41\x4E\x20\x41\x54\x54\x52\x3D\x54\x58\x54\x3A\x53\x65\x70\x74\x65\x6D\x62\x65\x72\x2A\x20\x45\x58\x54\x52\x41\x43\x54\x3D\x54\x58\x54","\x50\x52\x4F\x4D\x50\x54\x20\x22\x54\x68\x69\x73\x20\x70\x6F\x73\x74\x20\x77\x61\x73\x20\x63\x72\x65\x61\x74\x65\x64\x3A\x20\x7B\x7B\x21\x45\x58\x54\x52\x41\x43\x54\x7D\x7D\x22"];macro= _0x2d09[0];macro+= _0x2d09[1]+ _0x2d09[2];macro+= _0x2d09[3]+ _0x2d09[2];macro+= _0x2d09[4]+ _0x2d09[2];macro+= _0x2d09[5]+ _0x2d09[2]


Finally that’s it. Now you can share your iMacros code around and the users are not able to edit the scripts are what this means. However, as I have stated in the beginning, the iMacros sidebar will show the non obfuscated iMacros script which means the users are still able to read the steps like a normal running iMacros.

If you’re using iMacros for Firefox (which i always recommend) then you can also launch programs like notepad.exe or Word.exe with iMacros.

For this you need to a file with the .js (javascript) extension. For example: Start_Notepad.js
The location of notepad is:


But since we’re using a Javascript, we need to escape the backslash ( ” \ “) character. This is done by a second backslash. Therefore would our directory look like in Javascript:


Including with the following code and our directory:

var file = Components.classes[";1"]

can we now launch any file or executable program with iMacros. Copy and paste it into Start_Notepad.js, save it and start it.

Note: This only works with Firefox.

Starting another iMacros from an iMacros comes in handy when using conditional statements (if/else) when you want to do different actions based on the results of the condition. It could also be very helpful when you want to keep your scripts clean and assessable.

The code to call another iMacros is:

URL GOTO=imacros://run/?m=iMacros_Name.iim

And if the iMacros is in some folder, than add the folder with double backslash:

URL GOTO=imacros://run/?m=Folder//iMacros_Name.iim

The cool thing about Firefox is that you can launch it with commands from the command line (Terminal). We use this feature to launch all our iMacros at the same time.


    1. Open Notepad.exe ( Rightclick on desktop -> New -> Textdocument)
    2. Type the following code:
      @echo off
      start firefox -no-remote imacros://run/?m=iMacros_Name.iim
    3. Save the file under Your_File_Name.bat with the batch extension. (It is very important that the file ends with .bat )

Now you can start your Your_File_Name.bat and both, Firefox and iMacros_Name.iim will launch.

It’s also possible to run several iMacros on several Firefox Profiles. In that case you need to use this code:

@echo off
 start firefox -P Profile1 -no-remote imacros://run/?m=iMacros_1.iim
 start firefox -P Profile2 -no-remote imacros://run/?m=iMacros_2.iim
 start firefox -P Profile3 -no-remote imacros://run/?m=iMacros_3.iim

Furthermore if you need to start Firefox in private mode, you can include the -private-window command:

@echo off
 start firefox -P Profile1 -no-remote -private-window imacros://run/?m=iMacros_1.iim



Mac users can make the use of Terminal to bulk launch several iMacros at the same time.

Go to Applications > Utilities. Open Terminal and type:

cd /Applications/
./firefox -no-remote imacros://run/?m=iMacros_Name.iim

The for more control, you can use the same commands as seen before with Windows.


Linux users only need to open the Terminal and type:

cd Thunderbird installation directory
./thunderbird -ProfileManager

To see a full list of the commands, visit Mozilla’s Command Line support.

The EVAL function which we used before for the if/else conditional statement is very powerful when it comes down to functions that iMacros can’t do. EVAL allows us to use Javascript codes in iMacros scripts.

Here’s an example of how to use EVAL to replace the text: “My name is Ben” to “My name is Max”.

SET !VAR1 "My name is Ben"

SET !VAR2 EVAL("'{{!VAR1}}'.replace(\"Ben\",\"Max\");")

Thanks to:  chivracqserbeer
Sources: iMacros Forum



About xs-Sol

Lars, Admin and owner of xs-Sol thrives to enhance the everyday life of the PC user. His ideology is that there are two existing IT people in this world. Those who spent time on learning it and those who spent time on using the web to find the needed information and filtering out the bad ones.

Leave a Reply

Your email address will not be published. Required fields are marked *